about summary refs log tree commit diff
path: root/intl/localealias.c
diff options
context:
space:
mode:
authorRoland McGrath <roland@gnu.org>1996-06-03 22:46:17 +0000
committerRoland McGrath <roland@gnu.org>1996-06-03 22:46:17 +0000
commit5f2eab4263a916625b42d6ad6990ca0f658bca88 (patch)
treefeab32882be0f3d49089a3f4d203aeb37a072e22 /intl/localealias.c
parent20328c396217915d148013fd8f119aeb9ed2da0c (diff)
downloadglibc-5f2eab4263a916625b42d6ad6990ca0f658bca88.tar.gz
glibc-5f2eab4263a916625b42d6ad6990ca0f658bca88.tar.xz
glibc-5f2eab4263a916625b42d6ad6990ca0f658bca88.zip
Mon Jun 3 21:03:54 1996 Roland McGrath <roland@delasyd.gnu.ai.mit.edu>
	* malloc/mcheck.c (freehook, reallochook): Handle null pointer args.

	* hurd/hurdsig.c (_hurd_internal_post_signal): When setting ACT to
	`ignore, resume the thread if SS_SUSPENDED, regardless of old action.

Sun Jun  2 20:14:30 1996  Andreas Schwab  <schwab@issan.informatik.uni-dortmund.de>

	* locale/programs/linereader.c (lr_open): Don't pass NULL to
	xstrdup; fix memory leak.
	(lr_close): Fix memory leak.

	* hurd/hurdsig.c (_hurd_internal_post_signal): When turning the action
Mon Jun  3 01:29:53 1996  Roland McGrath  <roland@delasyd.gnu.ai.mit.edu>

	* elf/link.h (struct link_map): Replace l_deps_loaded flag member with
	`struct link_map **l_searchlist'.
	* elf/dl-lookup.c (_dl_lookup_symbol): Make SYMBOL_SCOPE arg an array
	of two link_map ptrs.  Search the maps in the l_searchlist of each
	of the two elts that is non-null.
	* elf/dl-reloc.c (_dl_relocate_object): Pass proper SCOPE array.
	* elf/dl-runtime.c: Likewise.
	* elf/dlsym.c: Likewise.
	* elf/rtld.c (dl_main): Likewise.
Diffstat (limited to 'intl/localealias.c')
-rw-r--r--intl/localealias.c55
1 files changed, 52 insertions, 3 deletions
diff --git a/intl/localealias.c b/intl/localealias.c
index 17b912afb3..57c4a01588 100644
--- a/intl/localealias.c
+++ b/intl/localealias.c
@@ -77,6 +77,41 @@ void free ();
 # define strcasecmp __strcasecmp
 #endif
 
+
+/* For those loosing systems which don't have `alloca' we have to add
+   some additional code emulating it.  */
+#ifdef HAVE_ALLOCA
+/* Nothing has to be done.  */
+# define ADD_BLOCK(list, address) /* nothing */
+# define FREE_BLOCKS(list) /* nothing */
+#else
+struct block_list
+{
+  void *address;
+  struct block_list *next;
+};
+# define ADD_BLOCK(list, addr)						      \
+  do {									      \
+    struct block_list *newp = (struct block_list *) malloc (sizeof (*newp));  \
+    /* If we cannot get a free block we cannot add the new element to	      \
+       the list.  */							      \
+    if (newp != NULL) {							      \
+      newp->address = (addr);						      \
+      newp->next = (list);						      \
+      (list) = newp;							      \
+    }									      \
+  } while (0)
+# define FREE_BLOCKS(list)						      \
+  do {									      \
+    while (list != NULL) {						      \
+      struct block_list *old = list;					      \
+      list = list->next;						      \
+      free (old);							      \
+    }									      \
+  } while (0)
+#endif	/* have alloca */
+
+
 struct alias_map
 {
   const char *alias;
@@ -151,18 +186,25 @@ read_alias_file (fname, fname_len)
      const char *fname;
      int fname_len;
 {
+#ifndef HAVE_ALLOCA
+  struct block_list *alloca_list = NULL;
+#endif
   FILE *fp;
   char *full_fname;
   size_t added;
   static const char aliasfile[] = "/locale.alias";
 
   full_fname = (char *) alloca (fname_len + sizeof aliasfile);
+  ADD_BLOCK (block_list, full_fname);
   memcpy (full_fname, fname, fname_len);
   memcpy (&full_fname[fname_len], aliasfile, sizeof aliasfile);
 
   fp = fopen (full_fname, "r");
   if (fp == NULL)
-    return 0;
+    {
+      FREE_BLOCKS (block_list);
+      return 0;
+    }
 
   added = 0;
   while (!feof (fp))
@@ -227,14 +269,20 @@ read_alias_file (fname, fname_len)
 	      len = strlen (alias) + 1;
 	      tp = (char *) malloc (len);
 	      if (tp == NULL)
-		return added;
+		{
+		  FREE_BLOCKS (block_list);
+		  return added;
+		}
 	      memcpy (tp, alias, len);
 	      map[nmap].alias = tp;
 
 	      len = strlen (value) + 1;
 	      tp = (char *) malloc (len);
 	      if (tp == NULL)
-		return added;
+		{
+		  FREE_BLOCKS (block_list);
+		  return added;
+		}
 	      memcpy (tp, value, len);
 	      map[nmap].value = tp;
 
@@ -263,6 +311,7 @@ read_alias_file (fname, fname_len)
     qsort (map, nmap, sizeof (struct alias_map),
 	   (int (*) PARAMS ((const void *, const void *))) alias_compare);
 
+  FREE_BLOCKS (block_list);
   return added;
 }