mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
Fix memory debugging code
This commit is contained in:
parent
4854dcf0eb
commit
93e72649dc
@ -174,7 +174,7 @@ static void prvInsertBlockIntoFreeList( BlockLink_t *pxBlockToInsert );
|
|||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
/* The size of the structure placed at the beginning of each allocated memory
|
/* The size of the structure placed at the beginning of each allocated memory
|
||||||
block must by correctly byte aligned. */
|
block must be correctly byte aligned. */
|
||||||
static const uint32_t uxHeapStructSize = ( ( sizeof ( BlockLink_t ) + BLOCK_HEAD_LEN + BLOCK_TAIL_LEN + ( portBYTE_ALIGNMENT - 1 ) ) & ~portBYTE_ALIGNMENT_MASK );
|
static const uint32_t uxHeapStructSize = ( ( sizeof ( BlockLink_t ) + BLOCK_HEAD_LEN + BLOCK_TAIL_LEN + ( portBYTE_ALIGNMENT - 1 ) ) & ~portBYTE_ALIGNMENT_MASK );
|
||||||
|
|
||||||
/* Create a couple of list links to mark the start and end of the list. */
|
/* Create a couple of list links to mark the start and end of the list. */
|
||||||
@ -583,7 +583,7 @@ const HeapRegionTagged_t *pxHeapRegion;
|
|||||||
|
|
||||||
#if (configENABLE_MEMORY_DEBUG == 1)
|
#if (configENABLE_MEMORY_DEBUG == 1)
|
||||||
{
|
{
|
||||||
mem_debug_init(uxHeapStructSize, &xStart, pxEnd, &xMallocMutex, xBlockAllocatedBit);
|
mem_debug_init(uxHeapStructSize, &xStart, pxEnd, &xMallocMutex);
|
||||||
mem_check_all(0);
|
mem_check_all(0);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -22,9 +22,10 @@ typedef struct {
|
|||||||
|
|
||||||
/* Please keep this definition same as BlockLink_t */
|
/* Please keep this definition same as BlockLink_t */
|
||||||
typedef struct _os_block_t {
|
typedef struct _os_block_t {
|
||||||
struct _os_block_t *next;
|
struct _os_block_t *next; /*<< The next free block in the list. */
|
||||||
size_t size;
|
int size: 24; /*<< The size of the free block. */
|
||||||
unsigned int xtag;
|
int xtag: 7; /*<< Tag of this region */
|
||||||
|
int xAllocated: 1; /*<< 1 if allocated */
|
||||||
}os_block_t;
|
}os_block_t;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
@ -50,7 +51,7 @@ typedef struct _mem_dbg_ctl{
|
|||||||
#define OS_BLOCK(_b) ((os_block_t*)((debug_block_t*)((char*)(_b) + BLOCK_HEAD_LEN)))
|
#define OS_BLOCK(_b) ((os_block_t*)((debug_block_t*)((char*)(_b) + BLOCK_HEAD_LEN)))
|
||||||
#define DEBUG_BLOCK(_b) ((debug_block_t*)((char*)(_b) - BLOCK_HEAD_LEN))
|
#define DEBUG_BLOCK(_b) ((debug_block_t*)((char*)(_b) - BLOCK_HEAD_LEN))
|
||||||
#define HEAD_DOG(_b) ((_b)->head.dog)
|
#define HEAD_DOG(_b) ((_b)->head.dog)
|
||||||
#define TAIL_DOG(_b) (*(unsigned int*)((char*)(_b) + (((_b)->os_block.size & (~g_alloc_bit) ) - BLOCK_TAIL_LEN)))
|
#define TAIL_DOG(_b) (*(unsigned int*)((char*)(_b) + (((_b)->os_block.size ) - BLOCK_TAIL_LEN)))
|
||||||
|
|
||||||
#define DOG_ASSERT()\
|
#define DOG_ASSERT()\
|
||||||
{\
|
{\
|
||||||
|
Loading…
x
Reference in New Issue
Block a user