Lines Matching refs:buf
33 abuf_init(struct abuf *buf, unsigned int len) in abuf_init() argument
35 buf->data = xmalloc(len); in abuf_init()
36 buf->len = len; in abuf_init()
37 buf->used = 0; in abuf_init()
38 buf->start = 0; in abuf_init()
42 abuf_done(struct abuf *buf) in abuf_done() argument
45 if (buf->used > 0) in abuf_done()
46 logx(3, "deleting non-empty buffer, used = %d", buf->used); in abuf_done()
48 xfree(buf->data); in abuf_done()
49 buf->data = (void *)0xdeadbeef; in abuf_done()
56 abuf_rgetblk(struct abuf *buf, int *rsize) in abuf_rgetblk() argument
60 count = buf->len - buf->start; in abuf_rgetblk()
61 if (count > buf->used) in abuf_rgetblk()
62 count = buf->used; in abuf_rgetblk()
64 return buf->data + buf->start; in abuf_rgetblk()
71 abuf_rdiscard(struct abuf *buf, int count) in abuf_rdiscard() argument
74 if (count < 0 || count > buf->used) { in abuf_rdiscard()
79 buf->used -= count; in abuf_rdiscard()
80 buf->start += count; in abuf_rdiscard()
81 if (buf->start >= buf->len) in abuf_rdiscard()
82 buf->start -= buf->len; in abuf_rdiscard()
89 abuf_wcommit(struct abuf *buf, int count) in abuf_wcommit() argument
92 if (count < 0 || count > (buf->len - buf->used)) { in abuf_wcommit()
97 buf->used += count; in abuf_wcommit()
104 abuf_wgetblk(struct abuf *buf, int *rsize) in abuf_wgetblk() argument
108 end = buf->start + buf->used; in abuf_wgetblk()
109 if (end >= buf->len) in abuf_wgetblk()
110 end -= buf->len; in abuf_wgetblk()
111 avail = buf->len - buf->used; in abuf_wgetblk()
112 count = buf->len - end; in abuf_wgetblk()
116 return buf->data + end; in abuf_wgetblk()