#include #include #include "msgpack.h" MsgPacket * msgpacket_new(void *data, int len) { MsgPacket *p; if ((p = malloc(sizeof(*p))) == NULL) { perror("msgpacket_new"); exit(1); } p->next = 0; p->p = p->buf = data; p->len = len; return p; } void msgpacket_delete(MsgPacket *p) { if (p) { if (p->buf) free(p->buf); free(p); } } void msgpacketlist_delete(MsgPacketList l) { MsgPacket *p = l, *q; while (p != NULL) { q = p; p = p->next; msgpacket_delete(q); } }