diff options
author | gdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2008-08-29 17:31:01 +0000 |
---|---|---|
committer | gdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2008-08-29 17:31:01 +0000 |
commit | 79bedccb6c48dfadc47ac91549ba0043d3ab9e53 (patch) | |
tree | e8209d3d033294e95d50207d392d7655a6b143bf /src/chheap.c | |
parent | 5eff277ef42641d64c066fa69b3a6a84cce8053f (diff) | |
download | ChibiOS-79bedccb6c48dfadc47ac91549ba0043d3ab9e53.tar.gz ChibiOS-79bedccb6c48dfadc47ac91549ba0043d3ab9e53.tar.bz2 ChibiOS-79bedccb6c48dfadc47ac91549ba0043d3ab9e53.zip |
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@416 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'src/chheap.c')
-rw-r--r-- | src/chheap.c | 30 |
1 files changed, 22 insertions, 8 deletions
diff --git a/src/chheap.c b/src/chheap.c index faa3cc42f..3069d5be6 100644 --- a/src/chheap.c +++ b/src/chheap.c @@ -184,20 +184,32 @@ void chHeapFree(void *p) { }
/**
- * Checks if the heap is non-empty and non-fragmented.
- * @return \p TRUE if the condition is satisfied
+ * Determines the heap status.
+ * @sizep pointer to a variable that will receive the total fragmented free
+ * space
+ * @return the number of fragments in the heap
* @note This function is meant to be used in the test suite, it should not be
* really useful for the application code.
*/
-bool_t chHeapNotFragmented(void) {
- bool_t b;
+size_t chHeapStatus(size_t *sizep) {
+ struct header *qp;
+ size_t n, sz;
H_LOCK();
- b = (heap.free.h_next != NULL) && (heap.free.h_next->h_next == NULL);
+ sz = 0;
+ for (n = 0, qp = &heap.free; qp->h_next; n++, qp = qp->h_next)
+ sz += qp->h_next->h_size;
+ if (sizep)
+ *sizep = sz;
+
+// if ((heap.free.h_next != NULL) && (heap.free.h_next->h_next == NULL))
+// n = heap.free.h_next->h_size;
+// else
+// n = 0;
H_UNLOCK();
- return b;
+ return n;
}
#else /* CH_USE_MALLOC_HEAP */
@@ -245,9 +257,11 @@ void chHeapFree(void *p) { H_UNLOCK();
}
-bool_t chHeapNotFragmented(void) {
+size_t chHeapStatus(size_t *sizep) {
- return FALSE;
+ if (sizep)
+ *sizep = 0;
+ return 0;
}
#endif /* CH_USE_MALLOC_HEAP */
|