Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/c/65.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C 在释放结构后检查它是否被释放_C_Data Structures_Struct_Linked List_Free - Fatal编程技术网

C 在释放结构后检查它是否被释放

C 在释放结构后检查它是否被释放,c,data-structures,struct,linked-list,free,C,Data Structures,Struct,Linked List,Free,我怎么能检查它是免费的还是不免费的,因为我不知道我是否做对了 对不起,我的英语不好 谢谢。要检查地址是否免费,只需检查地址是否等于空即可 void freestruct(LIST_T *linkedList) { linkedList->current = linkedList->head; if (linkedList != NULL) /* if list has been initialized */ { PERSON_T *

我怎么能检查它是免费的还是不免费的,因为我不知道我是否做对了

对不起,我的英语不好


谢谢。

要检查地址是否免费,只需检查地址是否等于空即可

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);
        }
}

因为您使用的是免费(linkedList),所以应该没问题。

linkedList!=空
使用后检查的时间太晚了。
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);
        }
}
linkedList == NULL