mirror of
https://sourceware.org/git/glibc.git
synced 2025-07-28 00:21:52 +03:00
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.
This commit is contained in:
@ -1,5 +1,14 @@
|
|||||||
2001-07-24 Ulrich Drepper <drepper@redhat.com>
|
2001-07-24 Ulrich Drepper <drepper@redhat.com>
|
||||||
|
|
||||||
|
* 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 (__gconv_lookup_cache): Catch one more
|
* iconv/gconv_cache.c (__gconv_lookup_cache): Catch one more
|
||||||
boundary case and reject it.
|
boundary case and reject it.
|
||||||
|
|
||||||
|
@ -177,13 +177,9 @@ find_module (const char *directory, const char *filename,
|
|||||||
{
|
{
|
||||||
size_t dirlen = strlen (directory);
|
size_t dirlen = strlen (directory);
|
||||||
size_t fnamelen = strlen (filename) + 1;
|
size_t fnamelen = strlen (filename) + 1;
|
||||||
char *fullname;
|
char fullname[dirlen + fnamelen];
|
||||||
int status = __GCONV_NOCONV;
|
int status = __GCONV_NOCONV;
|
||||||
|
|
||||||
fullname = (char *) malloc (dirlen + fnamelen);
|
|
||||||
if (fullname == NULL)
|
|
||||||
return __GCONV_NOMEM;
|
|
||||||
|
|
||||||
memcpy (__mempcpy (fullname, directory, dirlen), filename, fnamelen);
|
memcpy (__mempcpy (fullname, directory, dirlen), filename, fnamelen);
|
||||||
|
|
||||||
result->__shlib_handle = __gconv_find_shlib (fullname);
|
result->__shlib_handle = __gconv_find_shlib (fullname);
|
||||||
@ -191,7 +187,7 @@ find_module (const char *directory, const char *filename,
|
|||||||
{
|
{
|
||||||
status = __GCONV_OK;
|
status = __GCONV_OK;
|
||||||
|
|
||||||
result->__modname = fullname;
|
result->__modname = NULL;
|
||||||
result->__fct = result->__shlib_handle->fct;
|
result->__fct = result->__shlib_handle->fct;
|
||||||
result->__init_fct = result->__shlib_handle->init_fct;
|
result->__init_fct = result->__shlib_handle->init_fct;
|
||||||
result->__end_fct = result->__shlib_handle->end_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));
|
status = DL_CALL_FCT (result->__init_fct, (result));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (__builtin_expect (status, __GCONV_OK) != __GCONV_OK)
|
|
||||||
free (fullname);
|
|
||||||
|
|
||||||
return status;
|
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. */
|
/* Free all resources if necessary. */
|
||||||
static void __attribute__ ((unused))
|
static void __attribute__ ((unused))
|
||||||
free_mem (void)
|
free_mem (void)
|
||||||
|
@ -713,17 +713,24 @@ internal_function
|
|||||||
__gconv_close_transform (struct __gconv_step *steps, size_t nsteps)
|
__gconv_close_transform (struct __gconv_step *steps, size_t nsteps)
|
||||||
{
|
{
|
||||||
int result = __GCONV_OK;
|
int result = __GCONV_OK;
|
||||||
|
size_t cnt;
|
||||||
|
|
||||||
#ifndef STATIC_GCONV
|
|
||||||
/* Acquire the lock. */
|
/* Acquire the lock. */
|
||||||
__libc_lock_lock (lock);
|
__libc_lock_lock (lock);
|
||||||
|
|
||||||
while (nsteps-- > 0)
|
#ifndef STATIC_GCONV
|
||||||
__gconv_release_step (&steps[nsteps]);
|
cnt = nsteps;
|
||||||
|
while (cnt-- > 0)
|
||||||
|
__gconv_release_step (&steps[cnt]);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* If we use the cache we free a bit more since we don't keep any
|
||||||
|
transformation records around, they are cheap enough to
|
||||||
|
recreate. */
|
||||||
|
__gconv_release_cache (steps, nsteps);
|
||||||
|
|
||||||
/* Release the lock. */
|
/* Release the lock. */
|
||||||
__libc_lock_unlock (lock);
|
__libc_lock_unlock (lock);
|
||||||
#endif
|
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/* Handle loading/unloading of shared object for transformation.
|
/* Handle loading/unloading of shared object for transformation.
|
||||||
Copyright (C) 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
|
Copyright (C) 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
|
||||||
This file is part of the GNU C Library.
|
This file is part of the GNU C Library.
|
||||||
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
|
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
|
||||||
|
|
||||||
@ -83,11 +83,13 @@ __gconv_find_shlib (const char *name)
|
|||||||
if (keyp == NULL)
|
if (keyp == NULL)
|
||||||
{
|
{
|
||||||
/* This name was not known before. */
|
/* This name was not known before. */
|
||||||
found = malloc (sizeof (struct __gconv_loaded_object));
|
size_t namelen = strlen (name) + 1;
|
||||||
|
|
||||||
|
found = malloc (sizeof (struct __gconv_loaded_object) + namelen);
|
||||||
if (found != NULL)
|
if (found != NULL)
|
||||||
{
|
{
|
||||||
/* Point the tree node at this new structure. */
|
/* Point the tree node at this new structure. */
|
||||||
found->name = name;
|
found->name = (char *) memcpy (found + 1, name, namelen);
|
||||||
found->counter = -TRIES_BEFORE_UNLOAD - 1;
|
found->counter = -TRIES_BEFORE_UNLOAD - 1;
|
||||||
found->handle = NULL;
|
found->handle = NULL;
|
||||||
|
|
||||||
|
@ -210,6 +210,11 @@ extern int __gconv_close_transform (struct __gconv_step *steps,
|
|||||||
size_t nsteps)
|
size_t nsteps)
|
||||||
internal_function;
|
internal_function;
|
||||||
|
|
||||||
|
/* Free all resources allocated for the transformation record when
|
||||||
|
using the cache. */
|
||||||
|
extern void __gconv_release_cache (struct __gconv_step *steps, size_t nsteps)
|
||||||
|
internal_function;
|
||||||
|
|
||||||
/* Load shared object named by NAME. If already loaded increment reference
|
/* Load shared object named by NAME. If already loaded increment reference
|
||||||
count. */
|
count. */
|
||||||
extern struct __gconv_loaded_object *__gconv_find_shlib (const char *name)
|
extern struct __gconv_loaded_object *__gconv_find_shlib (const char *name)
|
||||||
|
@ -714,8 +714,6 @@ add_builtins (void)
|
|||||||
|
|
||||||
/* add the builtin transformations. */
|
/* add the builtin transformations. */
|
||||||
for (cnt = 0; cnt < nbuiltin_trans; ++cnt)
|
for (cnt = 0; cnt < nbuiltin_trans; ++cnt)
|
||||||
{
|
|
||||||
printf("%s: %s -> %s\n", builtin_trans[cnt].module,builtin_trans[cnt].from,builtin_trans[cnt].to);
|
|
||||||
new_module (builtin_trans[cnt].from,
|
new_module (builtin_trans[cnt].from,
|
||||||
strlen (builtin_trans[cnt].from) + 1,
|
strlen (builtin_trans[cnt].from) + 1,
|
||||||
builtin_trans[cnt].to,
|
builtin_trans[cnt].to,
|
||||||
@ -723,7 +721,6 @@ add_builtins (void)
|
|||||||
"", builtin_trans[cnt].module,
|
"", builtin_trans[cnt].module,
|
||||||
strlen (builtin_trans[cnt].module) + 1,
|
strlen (builtin_trans[cnt].module) + 1,
|
||||||
builtin_trans[cnt].cost, 0);
|
builtin_trans[cnt].cost, 0);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -60,7 +60,7 @@ endif
|
|||||||
librt-tests = ex10 ex11
|
librt-tests = ex10 ex11
|
||||||
tests = ex1 ex2 ex3 ex4 ex5 ex6 ex7 ex8 ex9 $(librt-tests) ex12 ex13 joinrace \
|
tests = ex1 ex2 ex3 ex4 ex5 ex6 ex7 ex8 ex9 $(librt-tests) ex12 ex13 joinrace \
|
||||||
tststack $(tests-nodelete-$(have-z-nodelete)) ecmutex ex14 ex15 ex16 \
|
tststack $(tests-nodelete-$(have-z-nodelete)) ecmutex ex14 ex15 ex16 \
|
||||||
ex17 tst-cancel
|
ex17 tst-cancel tst-context
|
||||||
|
|
||||||
ifeq (yes,$(build-shared))
|
ifeq (yes,$(build-shared))
|
||||||
tests-nodelete-yes = unload
|
tests-nodelete-yes = unload
|
||||||
|
Reference in New Issue
Block a user