Home | History | Annotate | Download | only in shared

Lines Matching refs:buf

24 void scratchbuf_init(struct scratchbuf *buf, char *stackbuf, size_t size)
26 buf->bytes = stackbuf;
27 buf->size = size;
28 buf->need_free = false;
31 int scratchbuf_alloc(struct scratchbuf *buf, size_t size)
35 if (size <= buf->size)
38 if (buf->need_free) {
39 tmp = realloc(buf->bytes, size);
46 memcpy(tmp, buf->bytes, buf->size);
49 buf->size = size;
50 buf->bytes = tmp;
51 buf->need_free = true;
56 void scratchbuf_release(struct scratchbuf *buf)
58 if (buf->need_free)
59 free(buf->bytes);