From: Ulrich Drepper Date: Sat, 8 Sep 2001 20:03:14 +0000 (+0000) Subject: Update. X-Git-Tag: cvs/glibc-2-2-5~295 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=1181062126ed5daf104aa9f7beb847055c1d4adc;p=platform%2Fupstream%2Fglibc.git Update. 2001-09-08 Ulrich Drepper * elf/dl-object.c: Avoid allocating extra memory block for name. * elf/dl-close.c (_dl_close): Don't free l_libname if it is no allocated separately. * elf/dl-load.c (_dl_map_object_from_fd): Likewise. --- diff --git a/ChangeLog b/ChangeLog index 6efa728..2eadb41 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2001-09-08 Ulrich Drepper + + * elf/dl-object.c: Avoid allocating extra memory block for name. + * elf/dl-close.c (_dl_close): Don't free l_libname if it is no + allocated separately. + * elf/dl-load.c (_dl_map_object_from_fd): Likewise. + 2001-09-08 H.J. Lu * po/zh_TW.po: Fix a typo. diff --git a/elf/dl-close.c b/elf/dl-close.c index 31b4863..de4b91a 100644 --- a/elf/dl-close.c +++ b/elf/dl-close.c @@ -254,7 +254,8 @@ _dl_close (void *_map) { struct libname_list *this = lnp; lnp = lnp->next; - free (this); + if (!this->dont_free) + free (this); } while (lnp != NULL); diff --git a/elf/dl-load.c b/elf/dl-load.c index cf05ad0..48c78c3 100644 --- a/elf/dl-load.c +++ b/elf/dl-load.c @@ -1099,7 +1099,8 @@ _dl_map_object_from_fd (const char *name, int fd, struct filebuf *fbp, /* We are not supposed to load this object. Free all resources. */ __munmap ((void *) l->l_map_start, l->l_map_end - l->l_map_start); - free (l->l_libname); + if (!l->l_libname->dont_free) + free (l->l_libname); if (l->l_phdr_allocated) free ((void *) l->l_phdr); diff --git a/elf/dl-object.c b/elf/dl-object.c index 65e90d6..bfd4f2d 100644 --- a/elf/dl-object.c +++ b/elf/dl-object.c @@ -40,15 +40,17 @@ _dl_new_object (char *realname, const char *libname, int type, struct link_map *new; struct libname_list *newname; - new = (struct link_map *) calloc (sizeof *new, 1); - newname = (struct libname_list *) malloc (sizeof *newname + libname_len); - if (new == NULL || newname == NULL) + new = (struct link_map *) calloc (sizeof (*new) + sizeof (*newname) + + libname_len, 1); + if (new == NULL) return NULL; - new->l_name = realname; + newname = (struct libname_list *) (new + 1); newname->name = (char *) memcpy (newname + 1, libname, libname_len); newname->next = NULL; - newname->dont_free = 0; + newname->dont_free = 1; + + new->l_name = realname; new->l_libname = newname; new->l_type = type; new->l_loader = loader;