aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--readme.txt4
-rw-r--r--src/chmempools.c50
-rw-r--r--src/include/mempools.h2
-rw-r--r--test/testpools.c2
4 files changed, 12 insertions, 46 deletions
diff --git a/readme.txt b/readme.txt
index b900210f8..17fd0056d 100644
--- a/readme.txt
+++ b/readme.txt
@@ -95,8 +95,8 @@ Win32-MinGW - ChibiOS/RT simulator and demo into a WIN32 process,
- FIX: The API chSemWaitTimeout() was missing in the documentation.
- CHANGE: Modified the chMtxUnlock() and chMtxUnlockS() APIs to return the
pointer to the released mutex instead of void.
-- CHANGE: Now the chThdResume() asserts that the thread is in PRSUSPEND state
- rather than test it.
+- CHANGE: Now the chThdResume() API asserts that the thread is in PRSUSPEND
+ state rather than test it.
- CHANGE: Removed the CH_USE_TERMINATE, CH_USE_SLEEP, CH_USE_SUSPEND and
CH_USE_RESUME configuration options in order to make the chconf.h file
simpler. The related functions are very small and almost always required.
diff --git a/src/chmempools.c b/src/chmempools.c
index 04d97a1f4..52914b7c6 100644
--- a/src/chmempools.c
+++ b/src/chmempools.c
@@ -27,54 +27,36 @@
#ifdef CH_USE_MEMPOOLS
/**
- * Initializes a memory pool.
+ * Initializes an empty memory pool.
* @param mp pointer to a \p MemoryPool structure
* @param size the size of the objects contained in this memory pool
- * @param allow_growth if \p TRUE then the memory pool can allocate
- * more space from the heap when needed
- * @note The parameter \p allow_growth is ignored if the \p CH_USE_HEAP
- * configuration option is not enabled.
*/
-void chPoolInit(MemoryPool *mp, size_t size, bool_t allow_growth) {
+void chPoolInit(MemoryPool *mp, size_t size) {
chDbgAssert((mp != NULL) && (size >= sizeof(void *)),
"chpools.c, chPoolFree()");
mp->mp_next = NULL;
mp->mp_object_size = size;
-#ifdef CH_USE_HEAP
- mp->mp_grow = allow_growth;
-#endif /* CH_USE_HEAP */
}
/**
* Allocates an object from a memory pool.
* @param mp pointer to a \p MemoryPool structure
- * @return the pointer to the allocated object or \p NULL if the memory is
- * exhausted
+ * @return the pointer to the allocated object or \p NULL if pool is empty
*/
void *chPoolAlloc(MemoryPool *mp) {
- void *p;
+ void *objp;
chDbgAssert(mp != NULL, "chpools.c, chPoolAlloc()");
chSysLock();
- if (mp->mp_next == NULL) {
-#ifdef CH_USE_HEAP
- if (mp->mp_grow) {
-
- chSysUnlock();
- return chHeapAlloc(mp->mp_object_size);
- }
-#endif /* CH_USE_HEAP */
- return NULL;
- }
- p = mp->mp_next;
- mp->mp_next = mp->mp_next->ph_next;
+ if ((objp = mp->mp_next) != NULL)
+ mp->mp_next = mp->mp_next->ph_next;
chSysUnlock();
- return p;
+ return objp;
}
/**
@@ -82,7 +64,7 @@ void *chPoolAlloc(MemoryPool *mp) {
* @param mp pointer to a \p MemoryPool structure
* @param objp the pointer to the object to be released or added
* @note the object is assumed to be of the right size for the specified
- * buffer.
+ * memory pool.
*/
void chPoolFree(MemoryPool *mp, void *objp) {
struct pool_header *php = objp;
@@ -98,22 +80,6 @@ void chPoolFree(MemoryPool *mp, void *objp) {
chSysUnlock();
}
-#ifdef CH_USE_HEAP
-/**
- * Releases all the objects contained into a pool.
- * @param mp pointer to a \p MemoryPool structure
- * @note It is assumed that all the object are allocated using the heap
- * allocator, do not use this function if the pool contains other kind
- * of objects, as example static areas.
- */
-void chPoolRelease(MemoryPool *mp) {
- void *p;
-
- while ((p = chPoolAlloc(mp)) != NULL)
- chHeapFree(p);
-}
-#endif
-
#endif /* CH_USE_MEMPOOLS */
/** @} */
diff --git a/src/include/mempools.h b/src/include/mempools.h
index 8311a757a..0037bf487 100644
--- a/src/include/mempools.h
+++ b/src/include/mempools.h
@@ -42,7 +42,7 @@ typedef struct {
#ifdef __cplusplus
extern "C" {
#endif
- void chPoolInit(MemoryPool *mp, size_t size, bool_t allow_growth);
+ void chPoolInit(MemoryPool *mp, size_t size);
void *chPoolAlloc(MemoryPool *mp);
void chPoolFree(MemoryPool *mp, void *objp);
#ifdef CH_USE_HEAP
diff --git a/test/testpools.c b/test/testpools.c
index 83614fcd5..40a31fad7 100644
--- a/test/testpools.c
+++ b/test/testpools.c
@@ -32,7 +32,7 @@ static char *pools1_gettest(void) {
static void pools1_setup(void) {
- chPoolInit(&mp1, UserStackSize(THREADS_STACK_SIZE), FALSE);
+ chPoolInit(&mp1, UserStackSize(THREADS_STACK_SIZE));
}
static void pools1_teardown(void) {