From 0db597422f2e5aa5a15342b95b56a0c1247af27f Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Tue, 24 Jul 2001 21:30:18 +0000 Subject: Update. * iconv/gconv_cache.c (find_module): Don't allocate room for the filename. Use alloca, we don't need it beyond this function. (__gconv_release_cache): New function. * iconv/gconv_db.c (__gconv_close_transform): Call __gconv_release_cache after the steps are handled. * iconv/gconv_dl.c (__gconv_find_shlib): Allocate file name in the record as well. * iconv/gconv_int.h: Add prototype fpr __gconv_release_cache. --- iconv/gconv_cache.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) (limited to 'iconv/gconv_cache.c') diff --git a/iconv/gconv_cache.c b/iconv/gconv_cache.c index 79e5dde..c664075 100644 --- a/iconv/gconv_cache.c +++ b/iconv/gconv_cache.c @@ -177,13 +177,9 @@ find_module (const char *directory, const char *filename, { size_t dirlen = strlen (directory); size_t fnamelen = strlen (filename) + 1; - char *fullname; + char fullname[dirlen + fnamelen]; int status = __GCONV_NOCONV; - fullname = (char *) malloc (dirlen + fnamelen); - if (fullname == NULL) - return __GCONV_NOMEM; - memcpy (__mempcpy (fullname, directory, dirlen), filename, fnamelen); result->__shlib_handle = __gconv_find_shlib (fullname); @@ -191,7 +187,7 @@ find_module (const char *directory, const char *filename, { status = __GCONV_OK; - result->__modname = fullname; + result->__modname = NULL; result->__fct = result->__shlib_handle->fct; result->__init_fct = result->__shlib_handle->init_fct; result->__end_fct = result->__shlib_handle->end_fct; @@ -201,9 +197,6 @@ find_module (const char *directory, const char *filename, status = DL_CALL_FCT (result->__init_fct, (result)); } - if (__builtin_expect (status, __GCONV_OK) != __GCONV_OK) - free (fullname); - return status; } @@ -409,6 +402,18 @@ __gconv_lookup_cache (const char *toset, const char *fromset, } +/* Free memory allocated for the transformation record. */ +void +internal_function +__gconv_release_cache (struct __gconv_step *steps, size_t nsteps) +{ + if (cache != NULL) + /* The only thing we have to deallocate is the record with the + steps. */ + free (steps); +} + + /* Free all resources if necessary. */ static void __attribute__ ((unused)) free_mem (void) -- cgit v1.1