This is the mail archive of the libc-hacker@sources.redhat.com mailing list for the glibc project.

Note that libc-hacker is a closed list. You may look at the archives of this list, but subscription and posting are not open.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Optimize other free_mem handlers, some more .bss shrinking


Hi!

This patch is on top of the 2002-10-26 one, frees some more space from
.bss and moves the remaining free_mem functions (together > ~ 2K on IA-32) to
separate section.
I'm afraid there is not much that can be done about inet_nsap_ntoa, since that
function apparently is not assumed to ever fail, so we cannot use malloc
which might fail. I've at least calculated properly the maximum size
of the buffer.
Still something might be done about utmp_file.c.

Another saving in PF_W|PF_R segment can be had after fixing gcc (see the
patch I posted yesterday).

2002-10-30  Jakub Jelinek  <jakub@redhat.com>

	* include/libc-symbols.h (__libc_freeres_fn_section, libc_freeres_fn):
	Define.
	* elf/dl-close.c (free_mem): Use libc_freeres_fn macro, remove
	text_set_element.
	* elf/dl-libc.c (free_mem): Likewise.
	* iconv/gconv_conf.c (free_mem): Likewise.
	* iconv/gconv_db.c (free_mem): Likewise.
	* iconv/gconv_dl.c (free_mem): Likewise.
	* iconv/gconv_cache.c (free_mem): Likewise.
	* intl/finddomain.c (free_mem): Likewise.
	* intl/dcigettext.c (free_mem): Likewise.
	* locale/setlocale.c (free_mem): Likewise.
	* misc/fstab.c (fstab_free): Likewise.
	* nss/nsswitch.c (free_mem): Likewise.
	* posix/regcomp.c (free_mem): Likewise.
	* resolv/gai_misc.c (free_res): Likewise.
	* stdlib/fmtmsg.c (free_mem): Likewise.
	* sunrpc/clnt_perr.c (free_mem): Likewise.
	* sysdeps/generic/setenv.c (free_mem): Likewise.
	* sysdeps/unix/sysv/linux/shm_open.c (freeit): Likewise.
	* sysdeps/pthread/aio_misc.c (free_res): Likewise.
	* time/tzset.c (free_mem): Likewise.
	* locale/loadarchive.c (_nl_archive_subfreeres): Add
	__libc_freeres_fn_section.
	* malloc/mtrace.c (release_libc_mem): Add __libc_freeres_fn_section.
	* malloc/set-freeres.c (__libc_freeres): Add
	__libc_freeres_fn_section.

	* login/getutent.c: Include stdlib.h instead of stddef.h.
	(buffer): Change into pointer to utmp, add libc_freeres_ptr.
	(__getutent): Allocate buffer the first time it is run.
	* login/getutid.c: Include stdlib.h instead of stddef.h.
	(buffer): Change into pointer to utmp, add libc_freeres_ptr.
	(__getutid): Allocate buffer the first time it is run.
	* login/getutline.c: Include stdlib.h instead of stddef.h.
	(buffer): Change into pointer to utmp, add libc_freeres_ptr.
	(__getutline): Allocate buffer the first time it is run.
	* malloc/mtrace.c (malloc_trace_buffer): Change into char *.
	(mtrace): Allocate malloc_trace_buffer.
	* resolv/nsap_addr.c (inet_nsap_ntoa): Decrease size of tmpbuf.
	* resolv/ns_print.c (ns_sprintrrf): Decrease size of t.
	* string/strerror.c: Include libintl.h and errno.h.
	(buf): New variable.
	(strerror): Only allocate buffer if actually needed (unknown error).
	* time/tzfile.c (transitions): Add libc_freeres_ptr.
	(freeres): Remove.

--- libc/elf/dl-close.c.jj	2002-10-24 21:23:40.000000000 +0200
+++ libc/elf/dl-close.c	2002-10-29 12:14:17.000000000 +0100
@@ -424,8 +424,7 @@ free_slotinfo (struct dtv_slotinfo_list 
 #endif
 
 
-static void
-free_mem (void)
+libc_freeres_fn (free_mem)
 {
   if (__builtin_expect (GL(dl_global_scope_alloc), 0) != 0
       && GL(dl_main_searchlist)->r_nlist == GL(dl_initial_searchlist).r_nlist)
@@ -453,4 +452,3 @@ free_mem (void)
     GL(dl_tls_dtv_slotinfo_list)->next = NULL;
 #endif
 }
-text_set_element (__libc_subfreeres, free_mem);
--- libc/elf/dl-libc.c.jj	2002-04-14 22:11:33.000000000 +0200
+++ libc/elf/dl-libc.c	2002-10-29 12:14:40.000000000 +0100
@@ -123,8 +123,7 @@ __libc_dlclose (void *__map)
 }
 
 
-static void
-free_mem (void)
+libc_freeres_fn (free_mem)
 {
   struct link_map *l;
   struct r_search_path_elem *d;
@@ -154,4 +153,3 @@ free_mem (void)
 	}
     }
 }
-text_set_element (__libc_subfreeres, free_mem);
--- libc/iconv/gconv_conf.c.jj	2002-03-23 11:50:26.000000000 +0100
+++ libc/iconv/gconv_conf.c	2002-10-29 12:17:42.000000000 +0100
@@ -597,11 +597,8 @@ __gconv_read_conf (void)
 
 
 /* Free all resources if necessary.  */
-static void __attribute__ ((unused))
-free_mem (void)
+libc_freeres_fn (free_mem)
 {
   if (__gconv_path_elem != NULL && __gconv_path_elem != &empty_path_elem)
     free ((void *) __gconv_path_elem);
 }
-
-text_set_element (__libc_subfreeres, free_mem);
--- libc/iconv/gconv_db.c.jj	2002-08-05 08:44:15.000000000 +0200
+++ libc/iconv/gconv_db.c	2002-10-29 12:18:06.000000000 +0100
@@ -778,8 +778,7 @@ free_modules_db (struct gconv_module *no
 
 
 /* Free all resources if necessary.  */
-static void __attribute__ ((unused))
-free_mem (void)
+libc_freeres_fn (free_mem)
 {
   if (__gconv_alias_db != NULL)
     __tdestroy (__gconv_alias_db, free);
@@ -790,5 +789,3 @@ free_mem (void)
   if (known_derivations != NULL)
     __tdestroy (known_derivations, free_derivation);
 }
-
-text_set_element (__libc_subfreeres, free_mem);
--- libc/iconv/gconv_dl.c.jj	2001-08-04 20:20:57.000000000 +0200
+++ libc/iconv/gconv_dl.c	2002-10-29 12:18:27.000000000 +0100
@@ -203,12 +203,10 @@ do_release_all (void *nodep)
   free (obj);
 }
 
-static void __attribute__ ((unused))
-free_mem (void)
+libc_freeres_fn (free_mem)
 {
   __tdestroy (loaded, do_release_all);
 }
-text_set_element (__libc_subfreeres, free_mem);
 
 
 #ifdef DEBUG
--- libc/iconv/gconv_cache.c.jj	2002-08-27 23:19:41.000000000 +0200
+++ libc/iconv/gconv_cache.c	2002-10-29 12:18:52.000000000 +0100
@@ -445,8 +445,7 @@ __gconv_release_cache (struct __gconv_st
 
 
 /* Free all resources if necessary.  */
-static void __attribute__ ((unused))
-free_mem (void)
+libc_freeres_fn (free_mem)
 {
   if (cache_malloced)
     free (gconv_cache);
@@ -455,5 +454,3 @@ free_mem (void)
     __munmap (gconv_cache, cache_size);
 #endif
 }
-
-text_set_element (__libc_subfreeres, free_mem);
--- libc/include/libc-symbols.h.jj	2002-10-25 23:49:37.000000000 +0200
+++ libc/include/libc-symbols.h	2002-10-29 12:24:26.000000000 +0100
@@ -265,6 +265,8 @@
 #  define libc_freeres_ptr(decl) \
   __make_section_unallocated ("__libc_freeres_ptrs, \"aw\", @nobits") \
   decl __attribute__ ((section ("__libc_freeres_ptrs" __sec_comment)))
+#  define __libc_freeres_fn_section \
+  __attribute__ ((section ("__libc_freeres_fn")))
 # else /* Not ELF: a.out */
 #  ifdef HAVE_XCOFF
 /* XCOFF does not support .stabs.
@@ -278,12 +280,18 @@
           ".stabs \"" __SYMBOL_PREFIX #symbol "\",1,0,0,0\n");
 #  endif /* XCOFF */
 #  define libc_freeres_ptr(decl) decl
+#  define __libc_freeres_fn_section
 # endif
 #else
 /* We will never be heard; they will all die horribly.  */
 # define link_warning(symbol, msg)
 # define libc_freeres_ptr(decl) decl
+# define __libc_freeres_fn_section
 #endif
+#define libc_freeres_fn(name)	\
+  static void name (void) __attribute_used__ __libc_freeres_fn_section;	\
+  text_set_element (__libc_subfreeres, name);				\
+  static void name (void)
 
 /* A canned warning for sysdeps/stub functions.  */
 #define	stub_warning(name) \
--- libc/intl/finddomain.c.jj	2002-07-29 15:14:51.000000000 +0200
+++ libc/intl/finddomain.c	2002-10-29 12:20:06.000000000 +0100
@@ -168,8 +168,7 @@ _nl_find_domain (dirname, locale, domain
 
 
 #ifdef _LIBC
-static void __attribute__ ((unused))
-free_mem (void)
+libc_freeres_fn (free_mem)
 {
   struct loaded_l10nfile *runp = _nl_loaded_domains;
 
@@ -183,6 +182,4 @@ free_mem (void)
       free (here);
     }
 }
-
-text_set_element (__libc_subfreeres, free_mem);
 #endif
--- libc/intl/dcigettext.c.jj	2002-09-24 13:00:06.000000000 +0200
+++ libc/intl/dcigettext.c	2002-10-29 12:20:29.000000000 +0100
@@ -1124,8 +1124,7 @@ mempcpy (dest, src, n)
 #ifdef _LIBC
 /* If we want to free all resources we have to do some work at
    program's end.  */
-static void __attribute__ ((unused))
-free_mem (void)
+libc_freeres_fn (free_mem)
 {
   void *old;
 
@@ -1155,6 +1154,4 @@ free_mem (void)
       free (old);
     }
 }
-
-text_set_element (__libc_subfreeres, free_mem);
 #endif
--- libc/locale/setlocale.c.jj	2002-09-01 09:34:28.000000000 +0200
+++ libc/locale/setlocale.c	2002-10-29 12:20:55.000000000 +0100
@@ -463,8 +463,7 @@ free_category (int category,
     }
 }
 
-static void __attribute__ ((unused))
-free_mem (void)
+libc_freeres_fn (free_mem)
 {
 #ifdef NL_CURRENT_INDIRECT
   /* We don't use the loop because we want to have individual weak
@@ -494,4 +493,3 @@ free_mem (void)
      not called _nl_unload_locale on them above.  */
   _nl_archive_subfreeres ();
 }
-text_set_element (__libc_subfreeres, free_mem);
--- libc/locale/loadarchive.c.jj	2002-09-01 15:33:18.000000000 +0200
+++ libc/locale/loadarchive.c	2002-10-29 12:25:28.000000000 +0100
@@ -493,7 +493,7 @@ _nl_load_locale_from_archive (int catego
   return lia->data[category];
 }
 
-void
+void __libc_freeres_fn_section
 _nl_archive_subfreeres (void)
 {
   struct locale_in_archive *lia;
--- libc/login/getutent.c.jj	2001-08-23 18:48:16.000000000 +0200
+++ libc/login/getutent.c	2002-10-29 16:24:04.000000000 +0100
@@ -1,4 +1,4 @@
-/* Copyright (C) 1996, 1997, 1998, 2001 Free Software Foundation, Inc.
+/* Copyright (C) 1996, 1997, 1998, 2001, 2002 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996.
 
@@ -17,12 +17,12 @@
    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
    02111-1307 USA.  */
 
-#include <stddef.h>		/* For NULL.  */
+#include <stdlib.h>
 #include <utmp.h>
 
 
 /* Local buffer to store the result.  */
-static struct utmp buffer;
+libc_freeres_ptr (static struct utmp *buffer);
 
 
 struct utmp *
@@ -30,7 +30,14 @@ __getutent (void)
 {
   struct utmp *result;
 
-  if (__getutent_r (&buffer, &result) < 0)
+  if (buffer == NULL)
+    {
+      buffer = (struct utmp *) malloc (sizeof (struct utmp));
+      if (buffer == NULL)
+        return NULL;
+    }
+
+  if (__getutent_r (buffer, &result) < 0)
     return NULL;
 
   return result;
--- libc/login/getutid.c.jj	2001-08-23 18:48:16.000000000 +0200
+++ libc/login/getutid.c	2002-10-29 16:24:20.000000000 +0100
@@ -1,4 +1,4 @@
-/* Copyright (C) 1996, 1997, 1998, 2001 Free Software Foundation, Inc.
+/* Copyright (C) 1996, 1997, 1998, 2001, 2002 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996.
 
@@ -17,20 +17,25 @@
    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
    02111-1307 USA.  */
 
-#include <stddef.h>		/* For NULL.  */
+#include <stdlib.h>
 #include <utmp.h>
 
 
 /* Local buffer to store the result.  */
-static struct utmp buffer;
-
+libc_freeres_ptr (static struct utmp *buffer);
 
 struct utmp *
 __getutid (const struct utmp *id)
 {
   struct utmp *result;
 
-  if (__getutid_r (id, &buffer, &result) < 0)
+  if (buffer == NULL)
+    {
+      buffer = (struct utmp *) malloc (sizeof (struct utmp));
+      if (buffer == NULL)
+        return NULL;
+    }
+  if (__getutid_r (id, buffer, &result) < 0)
     return NULL;
 
   return result;
--- libc/login/getutline.c.jj	2001-08-23 18:48:16.000000000 +0200
+++ libc/login/getutline.c	2002-10-29 16:40:18.000000000 +0100
@@ -1,4 +1,4 @@
-/* Copyright (C) 1996, 1997, 1998, 2001 Free Software Foundation, Inc.
+/* Copyright (C) 1996, 1997, 1998, 2001, 2002 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996.
 
@@ -17,12 +17,12 @@
    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
    02111-1307 USA.  */
 
-#include <stddef.h>		/* For NULL.  */
+#include <stdlib.h>
 #include <utmp.h>
 
 
 /* Local buffer to store the result.  */
-static struct utmp buffer;
+libc_freeres_ptr (static struct utmp *buffer);
 
 
 struct utmp *
@@ -30,7 +30,13 @@ __getutline (const struct utmp *line)
 {
   struct utmp *result;
 
-  if (__getutline_r (line, &buffer, &result) < 0)
+  if (buffer == NULL)
+    {
+      buffer = (struct utmp *) malloc (sizeof (struct utmp));
+      if (buffer == NULL)
+        return NULL;
+    }
+  if (__getutline_r (line, buffer, &result) < 0)
     return NULL;
 
   return result;
--- libc/malloc/mtrace.c.jj	2002-08-05 08:44:17.000000000 +0200
+++ libc/malloc/mtrace.c	2002-10-29 14:36:40.000000000 +0100
@@ -50,7 +50,7 @@
 
 static FILE *mallstream;
 static const char mallenv[]= "MALLOC_TRACE";
-static char malloc_trace_buffer[TRACE_BUFFER_SIZE];
+static char *malloc_trace_buffer;
 
 __libc_lock_define_initialized (static, lock);
 
@@ -237,7 +237,7 @@ tr_reallochook (ptr, size, caller)
 /* This function gets called to make sure all memory the library
    allocates get freed and so does not irritate the user when studying
    the mtrace output.  */
-static void
+static void __libc_freeres_fn_section
 release_libc_mem (void)
 {
   /* Only call the free function if we still are running in mtrace mode.  */
@@ -274,6 +274,10 @@ mtrace ()
 #endif
   if (mallfile != NULL || mallwatch != NULL)
     {
+      char *mtb = malloc (TRACE_BUFFER_SIZE);
+      if (mtb == NULL)
+	return;
+
       mallstream = fopen (mallfile != NULL ? mallfile : "/dev/null", "w");
       if (mallstream != NULL)
 	{
@@ -285,6 +289,7 @@ mtrace ()
 	      __fcntl (fileno (mallstream), F_SETFD, flags);
 	    }
 	  /* Be sure it doesn't malloc its buffer!  */
+	  malloc_trace_buffer = mtb;
 	  setvbuf (mallstream, malloc_trace_buffer, _IOFBF, TRACE_BUFFER_SIZE);
 	  fprintf (mallstream, "= Start\n");
 	  tr_old_free_hook = __free_hook;
@@ -303,6 +308,8 @@ mtrace ()
 	    }
 #endif
 	}
+      else
+	free (mtb);
     }
 }
 
--- libc/malloc/set-freeres.c.jj	2002-10-26 02:36:52.000000000 +0200
+++ libc/malloc/set-freeres.c	2002-10-29 12:27:17.000000000 +0100
@@ -29,7 +29,7 @@ DEFINE_HOOK (__libc_subfreeres, (void));
 
 symbol_set_define (__libc_freeres_ptrs);
 
-void
+void __libc_freeres_fn_section
 __libc_freeres (void)
 {
   /* This function might be called from different places.  So better
--- libc/misc/fstab.c.jj	2001-08-23 18:48:30.000000000 +0200
+++ libc/misc/fstab.c	2002-10-29 12:29:59.000000000 +0100
@@ -180,9 +180,7 @@ fstab_convert (struct fstab_state *state
 
 /* Make sure the memory is freed if the programs ends while in
    memory-debugging mode and something actually was allocated.  */
-static void
-__attribute__ ((unused))
-fstab_free (void)
+libc_freeres_fn (fstab_free)
 {
   char *buffer;
 
@@ -190,5 +188,3 @@ fstab_free (void)
   if (buffer != NULL)
     free ((void *) buffer);
 }
-
-text_set_element (__libc_subfreeres, fstab_free);
--- libc/nss/nsswitch.c.jj	2002-08-03 11:09:32.000000000 +0200
+++ libc/nss/nsswitch.c	2002-10-29 12:31:35.000000000 +0100
@@ -697,8 +697,7 @@ nss_new_service (name_database *database
 
 
 /* Free all resources if necessary.  */
-static void __attribute__ ((unused))
-free_mem (void)
+libc_freeres_fn (free_mem)
 {
   name_database *top = service_table;
   name_database_entry *entry;
@@ -745,5 +744,3 @@ free_mem (void)
 
   free (top);
 }
-
-text_set_element (__libc_subfreeres, free_mem);
--- libc/posix/regcomp.c.jj	2002-10-25 12:34:18.000000000 +0200
+++ libc/posix/regcomp.c	2002-10-29 12:33:06.000000000 +0100
@@ -696,12 +696,10 @@ re_comp (s)
 }
 
 #ifdef _LIBC
-static void __attribute__ ((unused))
-free_mem (void)
+libc_freeres_fn (free_mem)
 {
   __regfree (&re_comp_buf);
 }
-text_set_element (__libc_subfreeres, free_mem);
 #endif
 
 #endif /* _REGEX_RE_COMP */
--- libc/resolv/gai_misc.c.jj	2001-08-23 18:49:01.000000000 +0200
+++ libc/resolv/gai_misc.c	2002-10-29 12:33:37.000000000 +0100
@@ -410,9 +410,7 @@ handle_requests (void *arg)
 
 
 /* Free allocated resources.  */
-static void
-__attribute__ ((unused))
-free_res (void)
+libc_freeres_fn (free_res)
 {
   size_t row;
 
@@ -421,4 +419,3 @@ free_res (void)
 
   free (pool);
 }
-text_set_element (__libc_subfreeres, free_res);
--- libc/resolv/nsap_addr.c.jj	2000-07-27 15:59:40.000000000 +0200
+++ libc/resolv/nsap_addr.c	2002-10-29 14:27:32.000000000 +0100
@@ -70,7 +70,7 @@ char *
 inet_nsap_ntoa(int binlen, const u_char *binary, char *ascii) {
 	int nib;
 	int i;
-	static char tmpbuf[255*3];
+	static char tmpbuf[255*2 + 128];
 	char *start;
 
 	if (ascii)
--- libc/resolv/ns_print.c.jj	2000-07-27 15:59:40.000000000 +0200
+++ libc/resolv/ns_print.c	2002-10-29 14:30:06.000000000 +0100
@@ -309,7 +309,9 @@ ns_sprintrrf(const u_char *msg, size_t m
 		break;
 
 	case ns_t_nsap: {
-		char t[255*3];
+		/* 2*255 for hex digits, 128 for '.' and '\0', 2 for
+		   0x if inet_nsap_ntoa starts using it.  */
+		char t[255*2 + 128 + 2];
 
 		(void) inet_nsap_ntoa(rdlen, rdata, t);
 		T(addstr(t, strlen(t), &buf, &buflen));
--- libc/stdlib/fmtmsg.c.jj	2002-08-28 12:58:10.000000000 +0200
+++ libc/stdlib/fmtmsg.c	2002-10-29 12:34:07.000000000 +0100
@@ -390,8 +390,7 @@ addseverity (int severity, const char *s
 }
 
 
-static void __attribute__ ((unused))
-free_mem (void)
+libc_freeres_fn (free_mem)
 {
   struct severity_info *runp = severity_list;
 
@@ -407,4 +406,3 @@ free_mem (void)
     else
       runp = runp->next;
 }
-text_set_element (__libc_subfreeres, free_mem);
--- libc/string/strerror.c.jj	2001-08-21 22:30:38.000000000 +0200
+++ libc/string/strerror.c	2002-10-29 14:55:05.000000000 +0100
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991, 93, 94, 95, 96, 98 Free Software Foundation, Inc.
+/* Copyright (C) 1991, 93, 94, 95, 96, 98, 2002 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -16,16 +16,30 @@
    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
    02111-1307 USA.  */
 
+#include <libintl.h>
 #include <stdio.h>
 #include <string.h>
+#include <errno.h>
 
 /* Return a string describing the errno code in ERRNUM.
    The storage is good only until the next call to strerror.
    Writing to the storage causes undefined behavior.  */
+libc_freeres_ptr (static char *buf);
+
 char *
 strerror (errnum)
      int errnum;
 {
-  static char buf[1024];
-  return __strerror_r (errnum, buf, sizeof buf);
+  char *ret = __strerror_r (errnum, NULL, 0);
+  int saved_errno;
+
+  if (__builtin_expect (ret != NULL, 1))
+    return ret;
+  saved_errno = errno;
+  if (buf == NULL)
+    buf = malloc (1024);
+  __set_errno (saved_errno);
+  if (buf == NULL)
+    return _("Unknown error");
+  return __strerror_r (errnum, buf, 1024);
 }
--- libc/sunrpc/clnt_perr.c.jj	2002-08-06 10:15:16.000000000 +0200
+++ libc/sunrpc/clnt_perr.c	2002-10-29 12:35:44.000000000 +0100
@@ -413,9 +413,8 @@ auth_errmsg (enum auth_stat stat)
 }
 
 
-static void __attribute__ ((unused))
-free_mem (void)
+libc_freeres_fn (free_mem)
 {
+  /* Not libc_freeres_ptr, since buf is a macro.  */
   free (buf);
 }
-text_set_element (__libc_subfreeres, free_mem);
--- libc/sysdeps/generic/setenv.c.jj	2001-08-23 18:49:35.000000000 +0200
+++ libc/sysdeps/generic/setenv.c	2002-10-29 12:44:26.000000000 +0100
@@ -323,8 +323,7 @@ clearenv ()
   return 0;
 }
 #ifdef _LIBC
-static void
-free_mem (void)
+libc_freeres_fn (free_mem)
 {
   /* Remove all traces.  */
   clearenv ();
@@ -333,8 +332,6 @@ free_mem (void)
   __tdestroy (known_values, free);
   known_values = NULL;
 }
-text_set_element (__libc_subfreeres, free_mem);
-
 
 # undef setenv
 # undef unsetenv
--- libc/sysdeps/unix/sysv/linux/shm_open.c.jj	2002-09-09 13:08:14.000000000 +0200
+++ libc/sysdeps/unix/sysv/linux/shm_open.c	2002-10-29 12:45:13.000000000 +0100
@@ -226,14 +226,10 @@ shm_unlink (const char *name)
 }
 
 
-static void  __attribute__ ((unused))
-freeit (void)
+/* Make sure the table is freed if we want to free everything before
+   exiting.  */
+libc_freeres_fn (freeit)
 {
   if (mountpoint.dir != defaultdir)
     free (mountpoint.dir);
 }
-
-
-/* Make sure the table is freed if we want to free everything before
-   exiting.  */
-text_set_element (__libc_subfreeres, freeit);
--- libc/sysdeps/pthread/aio_misc.c.jj	2001-08-23 18:50:16.000000000 +0200
+++ libc/sysdeps/pthread/aio_misc.c	2002-10-29 12:45:41.000000000 +0100
@@ -665,9 +665,7 @@ handle_fildes_io (void *arg)
 
 
 /* Free allocated resources.  */
-static void
-__attribute__ ((unused))
-free_res (void)
+libc_freeres_fn (free_res)
 {
   size_t row;
 
@@ -676,7 +674,6 @@ free_res (void)
 
   free (pool);
 }
-text_set_element (__libc_subfreeres, free_res);
 
 
 /* Add newrequest to the runlist. The __abs_prio flag of newrequest must
--- libc/time/tzfile.c.jj	2001-08-23 18:51:42.000000000 +0200
+++ libc/time/tzfile.c	2002-10-29 12:46:49.000000000 +0100
@@ -49,7 +49,7 @@ static struct ttinfo *find_transition (t
 static void compute_tzname_max (size_t) internal_function;
 
 static size_t num_transitions;
-static time_t *transitions;
+libc_freeres_ptr (static time_t *transitions);
 static unsigned char *type_idxs;
 static size_t num_types;
 static struct ttinfo *types;
@@ -553,14 +553,3 @@ compute_tzname_max (size_t chars)
     }
   while (++p < &zone_names[chars]);
 }
-
-/* This function is only called when we are checking for memory leaks.  */
-static void
-freeres (void)
-{
-  if (transitions != NULL)
-    free ((void *) transitions);
-}
-
-/* Make sure all allocated data is freed before exiting.  */
-text_set_element (__libc_subfreeres, freeres);
--- libc/time/tzset.c.jj	2002-03-23 11:52:56.000000000 +0100
+++ libc/time/tzset.c	2002-10-29 12:47:12.000000000 +0100
@@ -624,8 +624,7 @@ __tz_convert (const time_t *timer, int u
 }
 
 
-static void
-free_mem (void)
+libc_freeres_fn (free_mem)
 {
   while (tzstring_list != NULL)
     {
@@ -637,4 +636,3 @@ free_mem (void)
   free (old_tz);
   old_tz = NULL;
 }
-text_set_element (__libc_subfreeres, free_mem);

	Jakub


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]