如何在C中释放枚举的内存以防止内存泄漏

如何在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 cannot free types. What are trying to do?
You should call free for memory allocated with malloc (or calloc, etc..), passing to the function the pointer to the allocated memory.