X-Git-Url: http://git.indexdata.com/?p=yaz-moved-to-github.git;a=blobdiff_plain;f=src%2Ficu_utf8.c;h=443adc8b0d2895d8f0650ca3a434b9f20ee425a0;hp=ee670a17912a0100737bc38032bd14c6b80c23d3;hb=730279e1d22e626f03e2d6817fbb78963d210a7a;hpb=d05e5d54fcac20824e0efa3d939e5fbb1505964a diff --git a/src/icu_utf8.c b/src/icu_utf8.c index ee670a1..443adc8 100644 --- a/src/icu_utf8.c +++ b/src/icu_utf8.c @@ -22,6 +22,7 @@ #include #include #include +#include #include /* some more string fcns*/ #include /* char names */ @@ -45,21 +46,17 @@ struct icu_buf_utf8 *icu_buf_utf8_create(size_t capacity) struct icu_buf_utf8 *icu_buf_utf8_clear(struct icu_buf_utf8 *buf8) { - if (buf8) - { - if (buf8->utf8) - buf8->utf8[0] = (uint8_t) 0; - buf8->utf8_len = 0; - } + assert(buf8); + if (buf8->utf8) + buf8->utf8[0] = (uint8_t) 0; + buf8->utf8_len = 0; return buf8; } struct icu_buf_utf8 *icu_buf_utf8_resize(struct icu_buf_utf8 *buf8, size_t capacity) { - if (!buf8) - return 0; - + assert(buf8); if (capacity > 0) { if (0 == buf8->utf8) @@ -70,19 +67,13 @@ struct icu_buf_utf8 *icu_buf_utf8_resize(struct icu_buf_utf8 *buf8, buf8->utf8_cap = capacity; } - else - { - xfree(buf8->utf8); - buf8->utf8 = 0; - buf8->utf8_cap = 0; - } - return buf8; } const char *icu_buf_utf8_to_cstr(struct icu_buf_utf8 *src8) { - if (!src8 || src8->utf8_len == 0) + assert(src8); + if (src8->utf8_len == 0) return ""; if (src8->utf8_len == src8->utf8_cap)