typedef struct tuple_ {
struct tuple_ *next;
enum TUPLE_FLAGS flags;
Packet *p;
int dir; // server or client
enum TCP_STATE state;
uint32_t server_ip; // 用来判断数据包是服务器发的包还是客户端发的包
unsigned long cs; // create tuple time
unsigned long expires; // 到期时间,释放掉
unsigned long last_communicate; // 最近通信时间
pthread_mutex_t mutex;
union {
struct http_context *http;
struct email_context *email;
//TODO ftp smb
};
}
我在程序中使用tuple->http=calloc(1, sizeof(struct http_context))申请内存,然后释放free(tuple->http)却出现了下面错误:
double free or corruption (out): 0x00007f3af0000920 ***
如果我把struct http_context *http; 定义放在union外面,就没问题。这是什么原因呢?哪位大佬能解释其中的yuan'l