From: Adam Dickmeiss Date: Tue, 15 Nov 2011 13:03:08 +0000 (+0100) Subject: Refactor icu_chain_create X-Git-Tag: v4.2.21~4 X-Git-Url: http://jsfdemo.indexdata.com/cgi-bin?a=commitdiff_plain;h=3f320e9bc56210d730081b2d82f2658636afa5ca;p=yaz-moved-to-github.git Refactor icu_chain_create And ensure proper clean up if UCollator can not be created. --- diff --git a/src/icu_chain.c b/src/icu_chain.c index 7bf8109..edb8d98 100644 --- a/src/icu_chain.c +++ b/src/icu_chain.c @@ -192,21 +192,17 @@ struct icu_chain_step *icu_chain_step_clone(struct icu_chain_step *old) struct icu_chain *icu_chain_create(const char *locale, int sort, UErrorCode *status) { - struct icu_chain *chain - = (struct icu_chain *) xmalloc(sizeof(*chain)); + struct icu_chain *chain; + UCollator *coll = ucol_open(locale, status); - *status = U_ZERO_ERROR; + if (U_FAILURE(*status)) + return 0; + chain = (struct icu_chain *) xmalloc(sizeof(*chain)); chain->iter = 0; chain->locale = xstrdup(locale); - chain->sort = sort; - - chain->coll = ucol_open(chain->locale, status); - - if (U_FAILURE(*status)) - return 0; - + chain->coll = coll; chain->csteps = 0; return chain;