Mercurial > hg > th-libs
diff th_datastruct.c @ 464:761724e01c02
Cleanups.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Thu, 10 May 2018 17:15:36 +0300 |
parents | 85fa3d333556 |
children | e4ce60239d16 |
line wrap: on
line diff
--- a/th_datastruct.c Thu May 10 16:04:15 2018 +0300 +++ b/th_datastruct.c Thu May 10 17:15:36 2018 +0300 @@ -415,16 +415,15 @@ } -BOOL th_growbuf_grow(th_growbuf_t *buf, const size_t grow) +BOOL th_growbuf_grow(th_growbuf_t *buf, const size_t amount) { if (buf == NULL) return FALSE; - if (buf->data == NULL || buf->len + grow >= buf->size) + if (buf->data == NULL || buf->len + amount >= buf->size) { - buf->size += grow + (buf->mingrow > 0 ? buf->mingrow : TH_BUFGROW); - buf->data = (uint8_t *) th_realloc(buf->data, buf->size); - if (buf->data == NULL) + buf->size += amount + (buf->mingrow > 0 ? buf->mingrow : TH_BUFGROW); + if ((buf->data = th_realloc(buf->data, buf->size)) == NULL) return FALSE; } return TRUE; @@ -459,15 +458,15 @@ } -BOOL th_growbuf_put_str(th_growbuf_t *buf, const void *s, const size_t len) +BOOL th_growbuf_put_str(th_growbuf_t *buf, const void *str, const size_t len) { - if (s == NULL) + if (str == NULL) return FALSE; if (!th_growbuf_grow(buf, len + 1)) return FALSE; - memcpy(buf->data + buf->len, s, len + 1); + memcpy(buf->data + buf->len, str, len + 1); buf->len += len; return TRUE;