X-Git-Url: http://git.indexdata.com/?p=yaz-moved-to-github.git;a=blobdiff_plain;f=src%2Ficu_utf16.c;h=962e90c7dd4856324fb34becd3a0391b93e50ca2;hp=3036d0aadc7a75202db2fdf7b757a69dc3869f7f;hb=cf91f233d0e16ed6920d84ce2d871eed90d3491b;hpb=16f1772479c5eac26f81dc29d5f9e3d5aeefab1c diff --git a/src/icu_utf16.c b/src/icu_utf16.c index 3036d0a..962e90c 100644 --- a/src/icu_utf16.c +++ b/src/icu_utf16.c @@ -1,5 +1,5 @@ /* This file is part of the YAZ toolkit. - * Copyright (C) 1995-2013 Index Data + * Copyright (C) Index Data * See the file LICENSE for details. */ @@ -46,21 +46,17 @@ struct icu_buf_utf16 *icu_buf_utf16_create(size_t capacity) struct icu_buf_utf16 *icu_buf_utf16_clear(struct icu_buf_utf16 *buf16) { - if (buf16) - { - if (buf16->utf16) - buf16->utf16[0] = (UChar) 0; - buf16->utf16_len = 0; - } + assert(buf16); + if (buf16->utf16) + buf16->utf16[0] = (UChar) 0; + buf16->utf16_len = 0; return buf16; } struct icu_buf_utf16 *icu_buf_utf16_resize(struct icu_buf_utf16 *buf16, size_t capacity) { - if (!buf16) - return 0; - + assert(buf16); if (capacity > 0) { if (0 == buf16->utf16) @@ -68,13 +64,8 @@ struct icu_buf_utf16 *icu_buf_utf16_resize(struct icu_buf_utf16 *buf16, else buf16->utf16 = (UChar *) xrealloc(buf16->utf16, sizeof(UChar) * capacity); + buf16->utf16_cap = capacity; } - else - { - xfree(buf16->utf16); - buf16->utf16 = 0; - } - buf16->utf16_cap = capacity; return buf16; }