Mercurial > hg > th-libs
comparison th_datastruct.c @ 445:6d29aaeab290
Add new function th_strbuf_putsn().
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Thu, 19 Oct 2017 17:37:04 +0300 |
parents | 2991e6b52d95 |
children | efd33accdc81 |
comparison
equal
deleted
inserted
replaced
444:1920a31927b2 | 445:6d29aaeab290 |
---|---|
566 | 566 |
567 return TRUE; | 567 return TRUE; |
568 } | 568 } |
569 | 569 |
570 | 570 |
571 BOOL th_strbuf_putsn(char **buf, size_t *bufsize, size_t *len, const char *str, const size_t slen) | |
572 { | |
573 if (str == NULL) | |
574 return FALSE; | |
575 | |
576 if (!th_strbuf_grow(buf, bufsize, len, slen + 1)) | |
577 return FALSE; | |
578 | |
579 memcpy(*buf + *len, str, slen); | |
580 (*len) += slen; | |
581 *(buf + *len + slen) = 0; | |
582 | |
583 return TRUE; | |
584 } | |
585 | |
586 | |
571 BOOL th_strbuf_puts(char **buf, size_t *bufsize, size_t *len, const char *str) | 587 BOOL th_strbuf_puts(char **buf, size_t *bufsize, size_t *len, const char *str) |
572 { | 588 { |
573 size_t slen; | 589 size_t slen; |
574 if (str == NULL) | 590 if (str == NULL) |
575 return FALSE; | 591 return FALSE; |