+2001-09-08 Ulrich Drepper <drepper@redhat.com>
+
+ * 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 <hjl@gnu.org>
* po/zh_TW.po: Fix a typo.
/* 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);
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;