Clarift uc_dstr_ensure
This commit is contained in:
+3
-3
@@ -22,13 +22,13 @@ size_t uc_dstr_available(const struct DStr *str)
|
||||
return str->allocated - str->len;
|
||||
}
|
||||
|
||||
int uc_dstr_ensure(struct DStr *str, size_t len)
|
||||
int uc_dstr_ensure(struct DStr *str, size_t total)
|
||||
{
|
||||
if (str->allocated < len) {
|
||||
if (str->allocated < total) {
|
||||
//allocate a minimum no. of bytes, and one
|
||||
//additional for the common case of nul terminating
|
||||
//the string
|
||||
size_t new_len = UC_MAX(7U, len) + 1;
|
||||
size_t new_len = UC_MAX(7U, total) + 1;
|
||||
char *new_str = realloc(str->str, new_len);
|
||||
|
||||
if (new_str == NULL) {
|
||||
|
||||
Reference in New Issue
Block a user