如何在C中释放枚举的内存以防止内存泄漏 [英] How to free memory of enum in C to prevent memory leak
本文介绍了如何在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.
这篇关于如何在C中释放枚举的内存以防止内存泄漏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文