From ff6163a0494434bb73926b42cfdc9681313fc662 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Fri, 29 Aug 2008 08:31:33 +0000 Subject: [PATCH] git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@414 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- docs/Doxyfile | 2 ++ docs/ch.txt | 32 ++++++++++++++++++++++++++++++++ src/chheap.c | 4 +++- src/chmempools.c | 5 +++-- 4 files changed, 40 insertions(+), 3 deletions(-) diff --git a/docs/Doxyfile b/docs/Doxyfile index 7f4432c52..4df239ac5 100644 --- a/docs/Doxyfile +++ b/docs/Doxyfile @@ -255,6 +255,8 @@ PREDEFINED = __JUST_STUBS__ \ CH_USE_QUEUES_HALFDUPLEX \ CH_USE_SERIAL_FULLDUPLEX \ CH_USE_SERIAL_HALFDUPLEX \ + CH_USE_HEAP \ + CH_USE_MEMPOOLS \ CH_USE_MESSAGES \ CH_USE_MESSAGES_EVENT \ CH_USE_MESSAGES_PRIORITY \ diff --git a/docs/ch.txt b/docs/ch.txt index a88291bb2..307dc6765 100644 --- a/docs/ch.txt +++ b/docs/ch.txt @@ -344,6 +344,38 @@ */ /** @} */ +/** + * @defgroup Heap Heap + * @{ + * Heap Allocator related APIs. + * Operation mode

+ * The heap allocator implements a first-fit strategy and its APIs are + * functionally equivalent to the usual \p malloc() and \p free(). The main + * difference is that the heap APIs are thread safe.
+ * By enabling the \p CH_USE_MALLOC_HEAP option the heap manager will use the + * runtime-provided \p malloc() and \p free() as backend for the heap APIs + * instead of the system provided allocator.
+ * In order to use the heap APIs the \p CH_USE_HEAP option must be specified + * in \p chconf.h. + * @file include/heap.h Heap macros and structures. + * @file chheap.c Heap functions. + */ +/** @} */ + +/** + * @defgroup MemoryPools Memory Pools + * @{ + * Memory Pools related APIs. + * Operation mode

+ * The Memory Pools APIs allow to allocate/free fixed size objects in + * constant time and reliably without memory fragmentation problems.
+ * In order to use the Time APIs the \p CH_USE_MEMPOOLS option must be + * specified in \p chconf.h. + * @file include/mempools.h Memory Pools macros and structures. + * @file chmempools.c Memory Pools functions. + */ +/** @} */ + /** * @defgroup Semaphores Semaphores * @{ diff --git a/src/chheap.c b/src/chheap.c index 0cda7f268..f4c80314d 100644 --- a/src/chheap.c +++ b/src/chheap.c @@ -18,7 +18,7 @@ */ /** - * @addtogroup Memory + * @addtogroup Heap * @{ */ @@ -251,3 +251,5 @@ bool_t chHeapNotFragmented(void) { #endif /* CH_USE_MALLOC_HEAP */ #endif /* CH_USE_HEAP */ + +/** @} */ diff --git a/src/chmempools.c b/src/chmempools.c index 49020d9b2..ae726122b 100644 --- a/src/chmempools.c +++ b/src/chmempools.c @@ -102,9 +102,10 @@ void chPoolFree(MemoryPool *mp, void *objp) { * of objects. */ void chPoolRelease(MemoryPool *mp) { + void *p; - while (mp->mp_next) - chHeapFree(mp->mp_next); + while ((p = chPoolAlloc(mp, FALSE)) != NULL) + chHeapFree(p); } #endif