Question

#include <stdio.h>
typedef struct _person
{
    char name[64];
    char gender[2];
    struct _person * pNext;
    struct _person * pPartner;
} PERSON_T;

typedef struct
{
    PERSON_T * head;
    PERSON_T * tail;
    PERSON_T * current;
} LIST_T;

I have the struct and then i free like this

void freestruct(LIST_T *linkedList)
{
    linkedList->current = linkedList->head;
    if (linkedList != NULL) /* if list has been initialized  */
        {
        PERSON_T * pThisItem = linkedList->head;
        while (pThisItem != NULL)
            {
            PERSON_T * pNext = pThisItem->pNext;
            free(pThisItem);
            pThisItem = pNext;
            }
        free(linkedList);
        }
}

How i can check that its free or not beacuse i dont know the functionfree that i made it right or not.

sorry about my english

Thank you.

Was it helpful?

Solution

To check whether an address is free or not it is enough to check the address equals to NULL.

linkedList == NULL

since you are using free(linkedList) it should be okay.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top