19 void *p = mallocz(size, 0);
21 fprint(2, "vtmalloc: out of memory allocating %lud", size);
24 setmalloctag(p, getcallerpc(&size));
31 void *p = mallocz(size, 1);
33 fprint(2, "vtmallocz: out of memory allocating %lud", size);
36 setmalloctag(p, getcallerpc(&size));
41 vtrealloc(void *p, ulong size)
44 if(p == 0 && size != 0){
45 fprint(2, "vtrealloc: out of memory allocating %lud", size);
48 setrealloctag(p, getcallerpc(&size));
57 static ulong nbuf, nchunk;
61 if(n >= IdealAlignment)
62 align = IdealAlignment;
71 sysfatal("Failed to allocate permanent chunk size %lud", n);
76 pad = (align - (uintptr)buf) & (align-1);
78 buf = sbrk(ChunkSize);
80 sysfatal("Failed to allocate permanent chunk size %ud", ChunkSize);
81 memset(buf, 0, ChunkSize);
83 pad = (align - (uintptr)buf) & (align-1);
87 assert(n + pad <= nbuf);