Ok I have a question, Ammaross wrote a bunch of code before he left, but he
didn't have much time to debugg it. Well with dmalloc it's showing that
we're leaking some memory from something he wrote. And I'm not sure exactly
how I would go about freeing it properly. So maybe someone can shead some
light on it.
char ** req_sock_names; // ok thats how the variable is defined... then he
does this.
obj->req_sockets = socket;
obj->req_sock_names = (char **) malloc( sizeof(char*) * (socket+1) );
for( int i = 0; i < socket; i++ )
obj->req_sock_names[i] = str_dup("");
obj->req_sock_names[socket] = NULL;
Ok thats how he sets it all up when something is socketed. And then he frees
it like this:
for( i = 0; i < obj->req_sockets && obj->req_sock_names[i] != NULL; i++ )
free_string( obj->req_sock_names[i] );
if (obj->req_sock_names)
free( obj->req_sock_names );
Ok so now as dmalloc goes about it's life it's telling me that this line:
obj->req_sock_names = (char **) malloc( sizeof(char*) * (socket+1) );
Is never getting freeed? but as I stepped through it all with gdb when it
does that first for loop to free it frees all those... And then the
req_sock_names is nothing. So how would I free that first peice of memory
that he allocated? Also anyone know of a good memory walk through site, or
possiably a book? Cause my big c++ book isn't much help, and I can't find
alot on memory allocating and freeing. Thanks in advance.