i get everything working but the unload function, there seems to be something wrong with free()
here' the code:
void freeChild(node* curr)
{ if(curr == NULL)
return;
for(int i = 0; i < 27; i++)
freeChild(curr->children[i]);
free(curr);
return;
}
bool unload(void)
{ freeChild(&root);
return true;
}
typedef struct node
{ bool is_end;
struct node* children[27];
} node;
node root = {false};
and it goes like this
*** Error in `./speller': free(): invalid pointer: 0x0804b04c ***
======= Backtrace: =========
/lib/libc.so.6[0x415e1cf2]
./speller[0x80492ff]
./speller[0x8049274]
./speller[0x8048d05]
/lib/libc.so.6(__libc_start_main+0xf3)[0x41585963]
======= Memory map: ========
08048000-0804a000 r-xp 00000000 fd:01 277991 /home/jharvard/Dropbox/pset6/speller
0804a000-0804b000 r--p 00001000 fd:01 277991 /home/jharvard/Dropbox/pset6/speller
0804b000-0804c000 rw-p 00002000 fd:01 277991 /home/jharvard/Dropbox/pset6/speller
09d12000-09d33000 rw-p 00000000 00:00 0 [heap]
41549000-41568000 r-xp 00000000 fd:01 401475 /usr/lib/ld-2.17.so
41568000-41569000 r--p 0001e000 fd:01 401475 /usr/lib/ld-2.17.so
41569000-4156a000 rw-p 0001f000 fd:01 401475 /usr/lib/ld-2.17.so
4156c000-41724000 r-xp 00000000 fd:01 401867 /usr/lib/libc-2.17.so
41724000-41725000 ---p 001b8000 fd:01 401867 /usr/lib/libc-2.17.so
41725000-41727000 r--p 001b8000 fd:01 401867 /usr/lib/libc-2.17.so
41727000-41728000 rw-p 001ba000 fd:01 401867 /usr/lib/libc-2.17.so
41728000-4172b000 rw-p 00000000 00:00 0
417b9000-417d4000 r-xp 00000000 fd:01 402104 /usr/lib/libgcc_s-4.8.1- 20130603.so.1
417d4000-417d5000 r--p 0001a000 fd:01 402104 /usr/lib/libgcc_s-4.8.1-20130603.so.1
417d5000-417d6000 rw-p 0001b000 fd:01 402104 /usr/lib/libgcc_s-4.8.1-20130603.so.1
b770f000-b7710000 rw-p 00000000 00:00 0
b771f000-b7723000 rw-p 00000000 00:00 0
b7723000-b7724000 r-xp 00000000 00:00 0 [vdso]
bfd57000-bfd78000 rw-p 00000000 00:00 0 [stack]
Aborted (core dumped)
will be really appreciate if someone could help!