aboutsummaryrefslogtreecommitdiffstats
path: root/src/chmempools.c
diff options
context:
space:
mode:
authorgdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2008-09-13 09:01:16 +0000
committergdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2008-09-13 09:01:16 +0000
commit8248aca2825c3650d0aeb43bb999b23fd2997804 (patch)
tree6e497e429f36d58dad4b625b2aecb163ea822e93 /src/chmempools.c
parente733a7d6624a92ee227c04ab81ad5b1efda88a65 (diff)
downloadChibiOS-8248aca2825c3650d0aeb43bb999b23fd2997804.tar.gz
ChibiOS-8248aca2825c3650d0aeb43bb999b23fd2997804.tar.bz2
ChibiOS-8248aca2825c3650d0aeb43bb999b23fd2997804.zip
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@432 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'src/chmempools.c')
-rw-r--r--src/chmempools.c50
1 files changed, 8 insertions, 42 deletions
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 */
/** @} */