mirror of https://github.com/rusefi/ChibiOS.git
Added new function chHeapIntegrityCheck().
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@15092 27425a3e-05d8-49a3-a47f-9c15f0e5edd8
This commit is contained in:
parent
8ab39c9118
commit
e1378a31ca
|
@ -160,6 +160,7 @@ extern "C" {
|
|||
void *chHeapAllocAligned(memory_heap_t *heapp, size_t size, unsigned align);
|
||||
void chHeapFree(void *p);
|
||||
size_t chHeapStatus(memory_heap_t *heapp, size_t *totalp, size_t *largestp);
|
||||
bool chHeapIntegrityCheck(memory_heap_t *heapp);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -415,7 +415,7 @@ size_t chHeapStatus(memory_heap_t *heapp, size_t *totalp, size_t *largestp) {
|
|||
*/
|
||||
bool chHeapIntegrityCheck(memory_heap_t *heapp) {
|
||||
bool result = false;
|
||||
heap_header_t *hp;
|
||||
heap_header_t *hp, *prevhp;
|
||||
|
||||
/* If an heap is not specified then the default system header is used.*/
|
||||
if (heapp == NULL) {
|
||||
|
@ -430,9 +430,22 @@ bool chHeapIntegrityCheck(memory_heap_t *heapp) {
|
|||
/* Taking heap mutex.*/
|
||||
H_LOCK(heapp);
|
||||
|
||||
prevhp = NULL;
|
||||
hp = &heapp->header;
|
||||
while ((hp = H_FREE_NEXT(hp)) != NULL) {
|
||||
|
||||
/* Order violation or loop.*/
|
||||
if (hp <= prevhp) {
|
||||
result = true;
|
||||
break;
|
||||
}
|
||||
|
||||
/* Checking pointer alignment.*/
|
||||
if (!MEM_IS_ALIGNED(hp, CH_HEAP_ALIGNMENT)) {
|
||||
result = true;
|
||||
break;
|
||||
}
|
||||
|
||||
/* Validating the found free block.*/
|
||||
if (!chMemIsAreaWithinX(&heapp->region,
|
||||
(void *)hp,
|
||||
|
@ -440,6 +453,8 @@ bool chHeapIntegrityCheck(memory_heap_t *heapp) {
|
|||
result = true;
|
||||
break;
|
||||
}
|
||||
|
||||
prevhp = hp;
|
||||
}
|
||||
|
||||
/* Releasing the heap mutex.*/
|
||||
|
|
|
@ -74,6 +74,7 @@
|
|||
*****************************************************************************
|
||||
|
||||
*** Next ***
|
||||
- NEW: Added new function chHeapIntegrityCheck().
|
||||
- NEW: Added EFL driver implementation for STM32G4xx.
|
||||
- NEW: Function chCoreGetStatusX() changed to return a memory region object
|
||||
instead of a simple size.
|
||||
|
|
Loading…
Reference in New Issue