Clarift uc_dstr_ensure

This commit is contained in:
Nils O. Selåsdal
2013-12-04 23:46:45 +01:00
parent b24f27ec9f
commit 9723a579cc
2 changed files with 9 additions and 5 deletions
+3 -3
View File
@@ -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) {