Open
Description
From https://public-inbox.org/git/[email protected]/:
This new way to initialize an strbuf
would set buf
to the specified constant string, the appropriate len = strlen(string)
, and alloc
to 0
.
That way, we can initialize strbufs with constant values, only allocating memory when/if needed.
We will need to be careful to revisit all strbuf_*()
functions to make sure that they test not only for enough space when growing the string, but also when reducing it (unless reducing to len == 0
, in which case we can reassign strbuf_slopbuf
to the buf
field).
We also will need to revisit strbuf_*()
to understand alloc < len
to mean that we cannot call realloc()
, but have to malloc() && memcpy()
instead.