summaryrefslogtreecommitdiff
path: root/src/buffer.c
diff options
context:
space:
mode:
authorVicent Marti <tanoku@gmail.com>2016-06-06 11:45:47 +0200
committerJohn MacFarlane <jgm@berkeley.edu>2016-06-06 15:39:06 -0700
commitfc1299a51ede05b3a76ae2f5a3ce882741a43a8b (patch)
treed8c8de49a2cb7c3bab832556e25f2648a7c6e8d0 /src/buffer.c
parent27376c2150df53d23995c0360a30152f68af5e7c (diff)
mem: Add a `realloc` pointer to the memory handler
Diffstat (limited to 'src/buffer.c')
-rw-r--r--src/buffer.c8
1 files changed, 1 insertions, 7 deletions
diff --git a/src/buffer.c b/src/buffer.c
index 12cbc56..e191056 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -50,14 +50,8 @@ void cmark_strbuf_grow(cmark_strbuf *buf, bufsize_t target_size) {
new_size += 1;
new_size = (new_size + 7) & ~7;
- unsigned char *new_ptr = buf->mem->calloc(new_size, 1);
- if (buf->ptr != cmark_strbuf__initbuf) {
- memcpy(new_ptr, buf->ptr, buf->size);
- buf->mem->free(buf->ptr);
- }
-
+ buf->ptr = buf->mem->realloc(buf->asize ? buf->ptr : NULL, new_size);
buf->asize = new_size;
- buf->ptr = new_ptr;
}
bufsize_t cmark_strbuf_len(const cmark_strbuf *buf) { return buf->size; }