相关疑难解决方法(0)

免费后将变量设置为NULL

在我的公司中,有一个编码规则,在释放任何内存后,将变量重置为NULL.例如 ...

void some_func () 
{
    int *nPtr;

    nPtr = malloc (100);

    free (nPtr);
    nPtr = NULL;

    return;
}
Run Code Online (Sandbox Code Playgroud)

我觉得,在上面显示的代码中,设置为NULL没有任何意义.或者我错过了什么?

如果在这种情况下没有任何意义,我将采用"质量团队"来删除此编码规则.请指教.

c malloc free coding-style heap-memory

146
推荐指数
11
解决办法
8万
查看次数

标签 统计

c ×1

coding-style ×1

free ×1

heap-memory ×1

malloc ×1