mfunyu / malloc

Find out the workings behind optimum memory management and recode it, as well as free and realloc.
2 stars 0 forks source link

[error] realloc on size change is no longer recognized #59

Closed mfunyu closed 5 months ago

mfunyu commented 5 months ago
$> MallocDebug=1 LD_PRELOAD=./libft_malloc.so bash    
[ malloc] by xmalloc      : malloc(16) = 0x7f552f3be170
[ malloc] by xmalloc      : malloc(16) = 0x7f552f3be190
[ malloc] by xmalloc      : malloc(16) = 0x7f552f3be1b0
[ malloc] by xmalloc      : malloc(16) = 0x7f552f3be1d0
[ malloc] by xmalloc      : malloc(16) = 0x7f552f3be1f0
[ malloc] by xmalloc      : malloc(16) = 0x7f552f3be210
[realloc] by xrealloc     : realloc(0x7f552f3aeb90, 1536)address: 0x7f552f3aeb80
magazine->type: 1
Error: pointer being realloc'd was not allocated
 -> terminated
[ malloc]                 : malloc(50) = 0x7f552f3be230
[   free]                 : free(0x7f552f3be230) -> terminated
[ malloc] by fopen        : malloc(472) = 0x7f552f3ad6e0
[ malloc] by _IO_file_doallocate : malloc(4096) = 0x7f5529089410
[realloc]                 : realloc(0x0, 1600) = 0x7f552908a610
[realloc]                 : realloc(0x0, 1024) = 0x7f552f3b57f0
[realloc]                 : realloc(0x7f552f3b57f0, 2048)address: 0x7f552f3b57e0
magazine->type: 1
Error: pointer being realloc'd was not allocated
 -> terminated
[   free] by _IO_setb     : free(0x7f5529089410) -> terminated
[   free] by fclose       : free(0x7f552f3ad6e0) -> terminated
[ malloc]                 : malloc(5) = 0x7f552f3be270
[ malloc]                 : malloc(55) = 0x7f552f3be230
[ malloc]                 : malloc(168) = 0x7f552f3ae2c0