* Set the length of the buffer to a given value. This function does *not* * allocate new memory, so you should not perform a `strbuf_setlen()` to a * length that is larger than `len + strbuf_avail()`. `strbuf_setlen()` is * just meant as a 'please fix invariants from this strbuf I just messed * with'. */
| 162 | * with'. |
| 163 | */ |
| 164 | static inline void strbuf_setlen(struct strbuf *sb, size_t len) |
| 165 | { |
| 166 | if (len > (sb->alloc ? sb->alloc - 1 : 0)) |
| 167 | BUG("strbuf_setlen() beyond buffer"); |
| 168 | sb->len = len; |
| 169 | if (sb->buf != strbuf_slopbuf) |
| 170 | sb->buf[len] = '\0'; |
| 171 | else |
| 172 | assert(!strbuf_slopbuf[0]); |
| 173 | } |
| 174 | |
| 175 | /** |
| 176 | * Empty the buffer by setting the size of it to zero. |
no outgoing calls