Mercurial > hg > nnchat
diff util.c @ 681:ceb73b712121
Fix an issue in editBuffer handling.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Mon, 09 Jul 2018 05:59:13 +0300 |
parents | f212cbfbd93c |
children | f3ec1cb11cea |
line wrap: on
line diff
--- a/util.c Mon Jul 02 00:04:53 2018 +0300 +++ b/util.c Mon Jul 09 05:59:13 2018 +0300 @@ -402,20 +402,24 @@ } -nn_editbuf_t * nn_editbuf_copy(nn_editbuf_t *src) +void nn_editbuf_copy_to(nn_editbuf_t *dst, const nn_editbuf_t *src) +{ + memcpy(dst->data, src->data, src->size); + dst->pos = dst->len = src->len; + dst->dirty = TRUE; +} + + +nn_editbuf_t * nn_editbuf_copy(const nn_editbuf_t *src) { nn_editbuf_t *res; - assert(src != NULL); - if (src == NULL) return NULL; if ((res = nn_editbuf_new(src->size)) == NULL) return NULL; - memcpy(res->data, src->data, src->size); - res->pos = res->len = src->len; - res->dirty = TRUE; + nn_editbuf_copy_to(res, src); return res; }