]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
(gen_steps): Set __counter initialy to 1.
authorUlrich Drepper <drepper@redhat.com>
Wed, 8 Dec 1999 04:34:17 +0000 (04:34 +0000)
committerUlrich Drepper <drepper@redhat.com>
Wed, 8 Dec 1999 04:34:17 +0000 (04:34 +0000)
(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.

iconv/gconv_db.c

index 4abc1ae48b631caadb359fd66da4b47a13b55d36..53cffa4dc73b47be11c373fd79117e3c835b4d30 100644 (file)
@@ -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