Closed DazzlingOkami closed 3 weeks ago
Update the call to traceMALLOC() to pass the actual size of the allocated block for secure_heap, heap2, heap4 and heap5.
test code:
// hook to freertos kernel #define traceMALLOC( pvAddress, uiSize ) trace_malloc(pvAddress, uiSize) #define traceFREE( pvAddress, uiSize ) trace_free(pvAddress, uiSize)
static int trace_enable = 0; static uint32_t malloc_total = 0; static uint32_t free_total = 0; void trace_malloc(void *ptr, uint32_t size){ if(trace_enable){ printf("=malloc= %p, %lu\r\n", ptr, size); malloc_total += size; } } void trace_free(void *ptr, uint32_t size){ if(trace_enable){ printf("= free = %p, %lu\r\n", ptr, size); free_total += size; } } int test_unit(void){ trace_enable = 1; void *p1 = pvPortMalloc(1016); void *p2 = pvPortMalloc(1016); void *p3 = pvPortMalloc(1016); vPortFree(p2); p2 = pvPortMalloc(1008); vPortFree(p1); vPortFree(p2); vPortFree(p3); trace_enable = 0; printf("malloc total: %lu\r\n", malloc_total); printf(" free total: %lu\r\n", free_total); return 0; }
Before the change, malloc_total and free_total printed by the above code are not same. After the change, they are same.
malloc_total
free_total
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
Issues 0 New issues 0 Accepted issues
Measures 0 Security Hotspots No data about Coverage No data about Duplication
See analysis details on SonarCloud
Description
Update the call to traceMALLOC() to pass the actual size of the allocated block for secure_heap, heap2, heap4 and heap5.
Test Steps
test code:
Before the change,
malloc_total
andfree_total
printed by the above code are not same. After the change, they are same.Checklist:
Related Issue
1078
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.