Bonsoir a tous, je déteste free , sans free sa marche impec ^^
mais lorsque j'essaye de free sa plante!!
j'ai un paragraphe énorme je comprend pas pourquoi
int malloc_options(t_map *m, int i)
{
int a;
a = 0;
if ((m->options = malloc(sizeof(int *) * i + 1)) == NULL)
return (-1);
while (a != i)
{
if ((m->options[a] = malloc(sizeof(int) * 1)) == NULL)
return (-1);
a++;
}
m->options[i + 1] = NULL;
return (0);
}
pour free je fais
void tab(int **tab){
int i = 0;
while (tab[i] != NULL)
{
free(tab[i]);
i++;
}
free(tab);
}
message d'erreur ..
- Error in `./a.out': free(): invalid next size (fast): 0x0000000001662700 ***
- Error in `./a.out': corrupted double-linked list: 0x00000000016626f0 ***
Inconsistency detected by ld.so: dl-open.c: 220: dl_open_worker: Assertion `_dl_debug_initialize (0, args->nsid)->r_state == RT_CONSISTENT' failed!
(boss-88)./a.out 5
- Error in `./a.out': free(): invalid next size (fast): 0x000000000212e700 ***
- Error in `./a.out': corrupted double-linked list: 0x000000000212e6f0 ***
Inconsistency detected by ld.so: dl-open.c: 220: dl_open_worker: Assertion `_dl_debug_initialize (0, args->nsid)->r_state == RT_CONSISTENT' failed!
(boss-89)./a.out 5
- Error in `./a.out': free(): invalid pointer: 0x0000000000e4b6b0 ***
======= Backtrace: =========
/lib64/libc.so.6(+0x7410f)[0x7fd28694010f]
/lib64/libc.so.6(+0x7996e)[0x7fd28694596e]
/lib64/libc.so.6(+0x7a647)[0x7fd286946647]
./a.out[0x401658]
./a.out[0x4015ef]
./a.out[0x400772]
/lib64/libc.so.6(__libc_start_main+0xf5)[0x7fd2868
edbe5]
./a.out[0x400609]
======= Memory map: ========
00400000-00402000 r-xp 00000000 08:07 526935 /home/test/a.out
00601000-00602000 r--p 00001000 08:07 526935 /home/test/a.out
00602000-00603000 rw-p 00002000 08:07 526935 /home/test/a.out
00e4b000-00e6c000 rw-p 00000000 00:00 0 [heap]
7fd2866b6000-7fd2866cb000 r-xp 00000000 08:05 397836 /lib64/libgcc_s.so.1
7fd2866cb000-7fd2868ca000 ---p 00015000 08:05 397836 /lib64/libgcc_s.so.1
7fd2868ca000-7fd2868cb000 r--p 00014000 08:05 397836 /lib64/libgcc_s.so.1
7fd2868cb000-7fd2868cc000 rw-p 00015000 08:05 397836 /lib64/libgcc_s.so.1
7fd2868cc000-7fd286a71000 r-xp 00000000 08:05 393227 /lib64/libc-2.18.so
7fd286a71000-7fd286c71000 ---p 001a5000 08:05 393227 /lib64/libc-2.18.so
7fd286c71000-7fd286c75000 r--p 001a5000 08:05 393227 /lib64/libc-2.18.so
7fd286c75000-7fd286c77000 rw-p 001a9000 08:05 393227 /lib64/libc-2.18.so
7fd286c77000-7fd286c7b000 rw-p 00000000 00:00 0
7fd286c7b000-7fd286c9b000 r-xp 00000000 08:05 395138 /lib64/ld-2.18.so
7fd286e79000-7fd286e7c000 rw-p 00000000 00:00 0
7fd286e98000-7fd286e9a000 rw-p 00000000 00:00 0
7fd286e9a000-7fd286e9b000 r--p 0001f000 08:05 395138 /lib64/ld-2.18.so
7fd286e9b000-7fd286e9c000 rw-p 00020000 08:05 395138 /lib64/ld-2.18.so
7fd286e9c000-7fd286e9d000 rw-p 00000000 00:00 0
7fff1f584000-7fff1f5a5000 rw-p 00000000 00:00 0 [stack]
7fff1f5fe000-7fff1f600000 r-xp 00000000 00:00 0 [vdso]
ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0 [vsyscall]
Aborted