Skip to content

Commit

Permalink
Add descriptive comment to string_reserve_space()
Browse files Browse the repository at this point in the history
This is useful both because it's unlike the other functions in the
same file and because it's worth noting explicitly that the caller
should update `String::len`.
  • Loading branch information
craigbarnes committed Dec 27, 2024
1 parent bd2eb62 commit 1b216c0
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/util/string.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ static COLD void string_grow(String *s, size_t min_alloc)
s->buffer = xrealloc(s->buffer, alloc);
}

// Reserve `more` bytes of additional space and return a pointer to the
// start of it, to allow writing directly to the buffer. Updating `s->len`
// to reflect the new length is left up to the caller.
char *string_reserve_space(String *s, size_t more)
{
BUG_ON(more == 0);
Expand Down

0 comments on commit 1b216c0

Please sign in to comment.