diff options
Diffstat (limited to 'iconv/gconv_db.c')
-rw-r--r-- | iconv/gconv_db.c | 68 |
1 files changed, 26 insertions, 42 deletions
diff --git a/iconv/gconv_db.c b/iconv/gconv_db.c index a441100df4..66e095d8c7 100644 --- a/iconv/gconv_db.c +++ b/iconv/gconv_db.c @@ -1,5 +1,5 @@ /* Provide access to the collection of available transformation modules. - Copyright (C) 1997-2016 Free Software Foundation, Inc. + Copyright (C) 1997-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997. @@ -121,7 +121,6 @@ static void *known_derivations; /* Look up whether given transformation was already requested before. */ static int -internal_function derivation_lookup (const char *fromset, const char *toset, struct __gconv_step **handle, size_t *nsteps) { @@ -143,7 +142,6 @@ derivation_lookup (const char *fromset, const char *toset, /* Add new derivation to list of known ones. */ static void -internal_function add_derivation (const char *fromset, const char *toset, struct __gconv_step *handle, size_t nsteps) { @@ -180,15 +178,14 @@ free_derivation (void *p) for (cnt = 0; cnt < deriv->nsteps; ++cnt) if (deriv->steps[cnt].__counter > 0 - && deriv->steps[cnt].__end_fct != NULL) + && deriv->steps[cnt].__shlib_handle != NULL) { - assert (deriv->steps[cnt].__shlib_handle != NULL); - __gconv_end_fct end_fct = deriv->steps[cnt].__end_fct; #ifdef PTR_DEMANGLE PTR_DEMANGLE (end_fct); #endif - DL_CALL_FCT (end_fct, (&deriv->steps[cnt])); + if (end_fct != NULL) + DL_CALL_FCT (end_fct, (&deriv->steps[cnt])); } /* Free the name strings. */ @@ -205,23 +202,18 @@ free_derivation (void *p) /* Decrement the reference count for a single step in a steps array. */ void -internal_function __gconv_release_step (struct __gconv_step *step) { /* Skip builtin modules; they are not reference counted. */ if (step->__shlib_handle != NULL && --step->__counter == 0) { /* Call the destructor. */ - if (step->__end_fct != NULL) - { - assert (step->__shlib_handle != NULL); - - __gconv_end_fct end_fct = step->__end_fct; + __gconv_end_fct end_fct = step->__end_fct; #ifdef PTR_DEMANGLE - PTR_DEMANGLE (end_fct); + PTR_DEMANGLE (end_fct); #endif - DL_CALL_FCT (end_fct, (step)); - } + if (end_fct != NULL) + DL_CALL_FCT (end_fct, (step)); #ifndef STATIC_GCONV /* Release the loaded module. */ @@ -235,7 +227,6 @@ __gconv_release_step (struct __gconv_step *step) } static int -internal_function gen_steps (struct derivation_step *best, const char *toset, const char *fromset, struct __gconv_step **handle, size_t *nsteps) { @@ -313,29 +304,30 @@ gen_steps (struct derivation_step *best, const char *toset, /* Call the init function. */ __gconv_init_fct init_fct = result[step_cnt].__init_fct; - if (init_fct != NULL) - { - assert (result[step_cnt].__shlib_handle != NULL); - # ifdef PTR_DEMANGLE - PTR_DEMANGLE (init_fct); + PTR_DEMANGLE (init_fct); # endif + if (init_fct != NULL) + { status = DL_CALL_FCT (init_fct, (&result[step_cnt])); if (__builtin_expect (status, __GCONV_OK) != __GCONV_OK) { failed = 1; - /* Make sure we unload this modules. */ - --step_cnt; + /* Do not call the end function because the init + function has failed. */ result[step_cnt].__end_fct = NULL; +# ifdef PTR_MANGLE + PTR_MANGLE (result[step_cnt].__end_fct); +# endif + /* Make sure we unload this module. */ + --step_cnt; break; } - + } # ifdef PTR_MANGLE - if (result[step_cnt].__btowc_fct != NULL) - PTR_MANGLE (result[step_cnt].__btowc_fct); + PTR_MANGLE (result[step_cnt].__btowc_fct); # endif - } } else #endif @@ -374,7 +366,6 @@ 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. */ @@ -411,20 +402,17 @@ increment_counter (struct __gconv_step *steps, size_t nsteps) /* These settings can be overridden by the init function. */ step->__btowc_fct = NULL; - } - /* Call the init function. */ - __gconv_init_fct init_fct = step->__init_fct; - if (init_fct != NULL) - { + /* Call the init function. */ + __gconv_init_fct init_fct = step->__init_fct; #ifdef PTR_DEMANGLE PTR_DEMANGLE (init_fct); #endif - DL_CALL_FCT (init_fct, (step)); + if (init_fct != NULL) + DL_CALL_FCT (init_fct, (step)); #ifdef PTR_MANGLE - if (step->__btowc_fct != NULL) - PTR_MANGLE (step->__btowc_fct); + PTR_MANGLE (step->__btowc_fct); #endif } } @@ -437,7 +425,6 @@ increment_counter (struct __gconv_step *steps, size_t nsteps) /* 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 -internal_function find_derivation (const char *toset, const char *toset_expand, const char *fromset, const char *fromset_expand, struct __gconv_step **handle, size_t *nsteps) @@ -717,7 +704,6 @@ do_lookup_alias (const char *name) int -internal_function __gconv_compare_alias (const char *name1, const char *name2) { int result; @@ -734,7 +720,6 @@ __gconv_compare_alias (const char *name1, const char *name2) int -internal_function __gconv_find_transform (const char *toset, const char *fromset, struct __gconv_step **handle, size_t *nsteps, int flags) @@ -800,7 +785,6 @@ __gconv_find_transform (const char *toset, const char *fromset, /* Release the entries of the modules list. */ int -internal_function __gconv_close_transform (struct __gconv_step *steps, size_t nsteps) { int result = __GCONV_OK; @@ -829,7 +813,7 @@ __gconv_close_transform (struct __gconv_step *steps, size_t nsteps) /* Free the modules mentioned. */ static void -internal_function __libc_freeres_fn_section +__libc_freeres_fn_section free_modules_db (struct gconv_module *node) { if (node->left != NULL) |