6 fmtzbinit(Fmt *f, ZBlock *b)
11 f->stop = (char*)f->start + b->len;
17 #define ROUNDUP(p, n) ((void*)(((uintptr)(p)+(n)-1)&~(uintptr)((n)-1)))
19 static char zmagic[] = "1234567890abcdefghijkl";
22 alloczblock(u32int size, int zeroed, uint blocksize)
30 blocksize = 32; /* try for cache line alignment */
32 n = size+32/*XXX*/+sizeof(ZBlock)+blocksize+8;
35 seterr(EOk, "out of memory");
39 data = ROUNDUP(p, blocksize);
40 b = ROUNDUP(data+size+32/*XXX*/, 8);
41 if(0) fprint(2, "alloc %p-%p data %p-%p b %p-%p\n",
42 p, p+n, data, data+size, b, b+1);
49 memset(b->data, 0, size);
50 memmove(b->data+size, zmagic, 32/*XXX*/);
58 if(memcmp(b->data+b->_size, zmagic, 32) != 0)
60 memset(b->data+b->_size, 0, 32);
66 packet2zblock(Packet *p, u32int size)
72 b = alloczblock(size, 0, 0);
75 if(packetcopy(p, b->data, 0, size) < 0){
83 zblock2packet(ZBlock *zb, u32int size)
90 packetappend(p, zb->data, size);