我们经常使用sturct,并在struct中添加..(*)(..)函数指针类型变量。例如
struct Global
{
int *a;
void(*func)(int); // 字符串处理
};
typedef struct Global Global;
void myFunc(int) ;
void intiMyGlobal(){
Global * b = (Global*)malloc(sizeof(Global)) ;
b->func = myFunc ;
}
void myFunc(int i){
//一堆代码;
}
如代码所属,有个问题想要请教:
当我们free(b)之前,我们是否需要先 free(b->func),还是说,不需要free掉b->func函数指针?为什么呢?