如何在C中释放枚举的内存以防止内存泄漏
问题描述:
如何释放C中枚举的内存以防止内存泄漏.
我们有免费的命令,但不能将其与enum一起使用,因为它不是指针类型.
例如:free(stoListItem-> et_Availability);
其中et_Availability是一个枚举.
我要释放它..
How to free memory of enum in C to prevent memory leak.
we have free command but we can''t use it with enum as its not a pointer type.
Ex: free(stoListItem->et_Availability);
where et_Availability is a enum.
I want to free it..
Anyone knows how to do it?
答
当然,您不能free
类型.正在尝试做什么?
您应该为分配给malloc
(或calloc
等)的内存调用free
,并将指向已分配内存的指针传递给函数 .
Of course you cannotfree
types. What are trying to do?
You should callfree
for memory allocated withmalloc
(orcalloc
, etc..), passing to the function the pointer to the allocated memory.