Fixed memory allocation bugs ... you don't free memory returned by getenv apparently.

This commit is contained in:
Stuart Longland 2008-03-25 10:07:38 +10:00
parent e04cca4ad9
commit 7a9f0694e9
3 changed files with 9 additions and 5 deletions

View File

@ -186,7 +186,8 @@ struct gallery_list* list_galleries() {
dprintf("list_galleries: read from %s\n",my_dir);
DIR* dir = opendir( my_dir );
if ( dir == NULL ) {
gcfree( my_dir );
dputs("list_galleries: couldn't open directory... returning NULL\n");
//gcfree( my_dir );
destroy_vararray( va );
return NULL;
}

View File

@ -435,7 +435,7 @@ char* resize_photo( struct photo_meta* dest,
char* dir = get_cgidir();
char* cache_path = construct_path( "s/s", dir, cache_file );
gcfree( dir );
//gcfree( dir );
/* Check if the file already exists... if it does, return now */
struct stat cache_stat;

View File

@ -12,10 +12,13 @@ struct mem_chunk* gc_find_chunk( void* ptr ) {
dprintf("gc_find_chunk: locating chunk for ptr %p\n", ptr);
struct mem_chunk* chunk = gc_head;
while( chunk != NULL )
if ( chunk->ptr == ptr )
if ( chunk->ptr == ptr ) {
dprintf("gc_find_chunk: located chunk for ptr %p at %p\n", ptr, chunk);
return chunk;
else
} else {
chunk = chunk->next;
}
dprintf("gc_find_chunk: chunk for ptr %p not found\n", ptr);
return NULL;
}
@ -88,7 +91,7 @@ void* gcrealloc( void* ptr, size_t size ) {
}
void gcfree( void* ptr ) {
dprintf("gcfree: freeing memory at %p\n", ptr);
dprintf("gcfree: freeing memory at %p (content: %10s...)\n", ptr, (char*)ptr);
struct mem_chunk* chunk = gc_find_chunk( ptr );
if ( chunk == NULL ) {
free( ptr );