Hi!
i have a structure malloc()'d, and after using them, i want to free() it, but my program freezes out here. Can anyone tell me, what i am doing wrong?
Here is my code:
struct data
{
char *filename;
char *size;
};
//primarypcs is a long type variable
struct data *primary = (struct data *)malloc( primarypcs * sizeof( struct data ) );
memset( primary, 0, sizeof(struct data *) * primarypcs );
...
...
...
for ( i = 0; i < primarypcs; i++ )
{
free( primary[i].filename ); //<----my program freezes here
free( primary[i].size ); //<----or here
}
free( primary );
Thanks in advance!
kampi
EDIT:
How can i correctly malloc memory for filename and size?
EDIT2:
Sorry, but i was in a hurry, and i didn't told you all the information that you need. Let me do it now :) Basicly, i want create an application, which gets the file list of two given drives/folders and then compares them. I thought (and still do), that the easiest way is, when i store the filenames and their size in a structure like mentioned above. So i have to allocate memory dynamically (i think this what they call it) for filename and size and of corse for the structure too.