From: Ulrich Drepper Date: Wed, 8 Dec 1999 04:34:17 +0000 (+0000) Subject: (gen_steps): Set __counter initialy to 1. X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=521c959a8ce560ea1bdba3a7521d13f25bdb6ef1;p=thirdparty%2Fglibc.git (gen_steps): Set __counter initialy to 1. (increment_counter): New function. Broken out of find_derivation. (find_derivation): No need for a lock. Increment counter only when the derivation was already available. --- diff --git a/iconv/gconv_db.c b/iconv/gconv_db.c index 4abc1ae48b6..53cffa4dc73 100644 --- a/iconv/gconv_db.c +++ b/iconv/gconv_db.c @@ -222,7 +222,7 @@ gen_steps (struct derivation_step *best, const char *toset, result[step_cnt].shlib_handle = shlib_handle; result[step_cnt].modname = shlib_handle->name; - result[step_cnt].counter = 0; + result[step_cnt].counter = 1; result[step_cnt].fct = shlib_handle->fct; result[step_cnt].init_fct = shlib_handle->init_fct; result[step_cnt].end_fct = shlib_handle->end_fct; @@ -281,6 +281,35 @@ gen_steps (struct derivation_step *best, const char *toset, } +#ifndef STATIC_GCONV +static int +internal_function +increment_counter (struct __gconv_step *steps, size_t nsteps) +{ + /* Increment the user counter. */ + size_t cnt = nsteps; + int result = __GCONV_OK; + + while (cnt-- > 0) + if (steps[cnt].__counter++ == 0) + { + steps[cnt].__shlib_handle = + __gconv_find_shlib (steps[cnt].__modname); + if (steps[cnt].__shlib_handle == NULL) + { + /* Oops, this is the second time we use this module (after + unloading) and this time loading failed!? */ + while (++cnt < nsteps) + __gconv_release_shlib (steps[cnt].__shlib_handle); + result = __GCONV_NOCONV; + break; + } + } + return result; +} +#endif + + /* The main function: find a possible derivation from the `fromset' (either the given name or the alias) to the `toset' (again with alias). */ static int