Hi!
I'm having problems freeing the Button[i].Items variable. Please take a look at the code.
Code:typedef struct BUTTON { short NoOfItems; char **Items; } BUTTON_COMPONENT; . . . for (i = 0; i < 3; i++) { if ((Button[i].Items = (char **) malloc (sizeof (char) * Button[i].NoOfItems)) == NULL) { ErrorMsg ("Button[i].Items is null!"); } else { if ((Button[i].Items[0] = (char *) malloc (sizeof (char) * (strlen ("First Button") + 1))) == NULL) { ErrorMsg ("Button[i].Items[0] is null!"); } if ((Button[i].Items[1] = (char *) malloc (sizeof (char) * (strlen ("Second Button") + 1))) == NULL) { ErrorMsg ("Button[i].Items[1] is null!"); } if ((Button[i].Items[2] = (char *) malloc (sizeof (char) * (strlen ("Third Button") + 1))) == NULL) { ErrorMsg ("Button[i].Items[2] is null!"); } } // do stuff for (j = 0; j < Button[i].NoOfItems; j++) { free (Button[i].Items[j]); Button[i].Items[j] = NULL; } free (Button[i].Items); // here is where the program hangs. Can someone please tell me WHY? Button[i].Items = NULL; }