ขนาดวิดีโอ: 1280 X 720853 X 480640 X 360
แสดงแผงควบคุมโปรแกรมเล่น
เล่นอัตโนมัติ
เล่นใหม่
In the function my_free , heap_small[ALLOC_CNT] and heap_large[ALLOC_CNT], both are OOB. It needs to be ALLOC_CNT - 1.
in free function should the ptr be subtracted from base address of addr and then we should do Modulo ?
Possible solutionfor (int i = 0; i < ALLOC_CNT; i++) { if (ptr == (void*)heap_small[i]) { used_small[i] = false; break; } if (ptr == (void*)heap_large[i]) { used_large[i] = false; break; } }
your my_free func have critical bug if (addr % HEAP_SMALL == 0) never happen
In the function my_free , heap_small[ALLOC_CNT] and heap_large[ALLOC_CNT], both are OOB. It needs to be ALLOC_CNT - 1.
in free function should the ptr be subtracted from base address of addr and then we should do Modulo ?
Possible solution
for (int i = 0; i < ALLOC_CNT; i++) {
if (ptr == (void*)heap_small[i]) {
used_small[i] = false;
break;
}
if (ptr == (void*)heap_large[i]) {
used_large[i] = false;
break;
}
}
your my_free func have critical bug if (addr % HEAP_SMALL == 0) never happen