hey, i'm have a "heap corruption" error while trying to free linked list.
my structs are:
Code:
typedef struct client
{
char* License;
struct client* next;
}client;
typedef struct station
{
char* sName;
client* clients;
struct station* next;
}station;
linked list of station, each with linked list of clients. stations and clients have a name type char* allocated by malloc.
i'm trying to free the list like this:
Code:
void FreeAll(station *st)
{
client *cl;
station* temp;
while (st != NULL)
{
cl = st->clients;
FreeClients(cl);
temp = st;
st = st->next;
free(temp->sName);
free(temp);
}
}
void FreeClients(client* cl)
{
client* temp;
while (cl != NULL)
{
temp = cl;
cl = cl->next;
free(temp->License);
free(temp);
}
}
when i get to free(temp->License); in FreeClients the program crashs down, using debugging i get "heap corruption" error...
thenks for your time...