Home | History | Annotate | Download | only in util

Lines Matching defs:len

22 	sb->alloc = sb->len = 0;
40 *sz = sb->len;
47 if (sb->len + extra + 1 <= sb->len)
51 ALLOC_GROW(sb->buf, sb->len + extra + 1, sb->alloc);
54 static void strbuf_splice(struct strbuf *sb, size_t pos, size_t len,
57 if (pos + len < pos)
59 if (pos > sb->len)
61 if (pos + len > sb->len)
62 die("`pos + len' is too far after the end of the buffer");
64 if (dlen >= len)
65 strbuf_grow(sb, dlen - len);
67 sb->buf + pos + len,
68 sb->len - pos - len);
70 strbuf_setlen(sb, sb->len + dlen - len);
73 void strbuf_remove(struct strbuf *sb, size_t pos, size_t len)
75 strbuf_splice(sb, pos, len, NULL, 0);
78 void strbuf_add(struct strbuf *sb, const void *data, size_t len)
80 strbuf_grow(sb, len);
81 memcpy(sb->buf + sb->len, data, len);
82 strbuf_setlen(sb, sb->len + len);
87 int len;
93 len = vsnprintf(sb->buf + sb->len, sb->alloc - sb->len, fmt, ap);
95 if (len < 0)
97 if (len > strbuf_avail(sb)) {
98 strbuf_grow(sb, len);
100 len = vsnprintf(sb->buf + sb->len, sb->alloc - sb->len, fmt, ap);
102 if (len > strbuf_avail(sb)) {
106 strbuf_setlen(sb, sb->len + len);
111 size_t oldlen = sb->len;
118 cnt = read(fd, sb->buf + sb->len, sb->alloc - sb->len - 1);
128 sb->len += cnt;
132 sb->buf[sb->len] = '\0';
133 return sb->len - oldlen;