comparison 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
comparison
equal deleted inserted replaced
680:7d4730232ee3 681:ceb73b712121
400 th_free(buf); 400 th_free(buf);
401 } 401 }
402 } 402 }
403 403
404 404
405 nn_editbuf_t * nn_editbuf_copy(nn_editbuf_t *src) 405 void nn_editbuf_copy_to(nn_editbuf_t *dst, const nn_editbuf_t *src)
406 {
407 memcpy(dst->data, src->data, src->size);
408 dst->pos = dst->len = src->len;
409 dst->dirty = TRUE;
410 }
411
412
413 nn_editbuf_t * nn_editbuf_copy(const nn_editbuf_t *src)
406 { 414 {
407 nn_editbuf_t *res; 415 nn_editbuf_t *res;
408 416
409 assert(src != NULL);
410
411 if (src == NULL) return NULL; 417 if (src == NULL) return NULL;
412 418
413 if ((res = nn_editbuf_new(src->size)) == NULL) 419 if ((res = nn_editbuf_new(src->size)) == NULL)
414 return NULL; 420 return NULL;
415 421
416 memcpy(res->data, src->data, src->size); 422 nn_editbuf_copy_to(res, src);
417 res->pos = res->len = src->len;
418 res->dirty = TRUE;
419 423
420 return res; 424 return res;
421 } 425 }
422 426
423 427