int packetconsume(Packet *p, uint8_t *buf, int n) { NOTFREE(p); if(buf && packetcopy(p, buf, 0, n) < 0) return -1; return packettrim(p, n, p->size-n); }
ZBlock* packet2zblock(Packet *p, uint32_t size) { ZBlock *b; if(p == nil) return nil; b = alloczblock(size, 0, 0); if(b == nil) return nil; if(packetcopy(p, b->data, 0, size) < 0){ freezblock(b); return nil; } return b; }