about summary refs log tree commit diff
path: root/iconv/gconv_db.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>1998-12-17 20:59:54 +0000
committerUlrich Drepper <drepper@redhat.com>1998-12-17 20:59:54 +0000
commit8c4796197c60fc8aa380d8995f0d744faf4d8c4a (patch)
tree8747f959e3e829d8bb70971f7e7017f73696b828 /iconv/gconv_db.c
parentc5b0e13e208bbc4722be3f45283e75d1333b4957 (diff)
downloadglibc-8c4796197c60fc8aa380d8995f0d744faf4d8c4a.tar.gz
glibc-8c4796197c60fc8aa380d8995f0d744faf4d8c4a.tar.xz
glibc-8c4796197c60fc8aa380d8995f0d744faf4d8c4a.zip
Update.
	* iconv/gconv_int.h (gconv_module): Add new element from_regex_mem.
	* iconv/gconv_conf.c (module_compare): Make s1 and s2 const.
	(detect_conflict): New function.
	(add_alias): Call detect_conflict to see whether there is already
	a module for the new name.
	(add_module): Make sure there is no alias for the new name.
	(read_conf_file): Call add_alias with new argument.
	(__gconv_read_conf): Don't destroy module tree immediately after
	walking it.  We need it to test the internal conversions for
	conflicts.
	* iconv/gconv_db.c (find_derivation): Don't allocate memory for
	regular expression.  There is now room in the module descriptor.
	(free_mem): Don't free memory for regular expression.
Diffstat (limited to 'iconv/gconv_db.c')
-rw-r--r--iconv/gconv_db.c28
1 files changed, 10 insertions, 18 deletions
diff --git a/iconv/gconv_db.c b/iconv/gconv_db.c
index f5a67ffbab..11914547c7 100644
--- a/iconv/gconv_db.c
+++ b/iconv/gconv_db.c
@@ -348,17 +348,14 @@ find_derivation (const char *toset, const char *toset_expand,
 		/* First compile the regex if not already done.  */
 		if (__gconv_modules_db[cnt]->from_regex == NULL)
 		  {
-		    regex_t *newp = (regex_t *) malloc (sizeof (regex_t));
-
-		    if (__regcomp (newp, __gconv_modules_db[cnt]->from_pattern,
+		    if (__regcomp (&__gconv_modules_db[cnt]->from_regex_mem,
+				   __gconv_modules_db[cnt]->from_pattern,
 				   REG_EXTENDED | REG_ICASE) != 0)
-		      {
-			/* Something is wrong.  Remember this.  */
-			free (newp);
-			__gconv_modules_db[cnt]->from_regex = (regex_t *) -1L;
-		      }
+		      /* Something is wrong.  Remember this.  */
+		      __gconv_modules_db[cnt]->from_regex = (regex_t *) -1L;
 		    else
-		      __gconv_modules_db[cnt]->from_regex = newp;
+		      __gconv_modules_db[cnt]->from_regex
+			= &__gconv_modules_db[cnt]->from_regex_mem;
 		  }
 
 		if (__gconv_modules_db[cnt]->from_regex != (regex_t *) -1L)
@@ -627,15 +624,10 @@ free_mem (void)
     __tdestroy (__gconv_alias_db, free);
 
   for (cnt = 0; cnt < __gconv_nmodules; ++cnt)
-    {
-      if (__gconv_modules_db[cnt]->from_regex != NULL)
-	__regfree ((regex_t *) __gconv_modules_db[cnt]->from_regex);
-
-      /* Modules which names do not start with a slash are builtin
-	 transformations and the memory is not allocated dynamically.  */
-      if (__gconv_modules_db[cnt]->module_name[0] == '/')
-	free (__gconv_modules_db[cnt]);
-    }
+    /* Modules which names do not start with a slash are builtin
+       transformations and the memory is not allocated dynamically.  */
+    if (__gconv_modules_db[cnt]->module_name[0] == '/')
+      free (__gconv_modules_db[cnt]);
 
   if (known_derivations != NULL)
     __tdestroy (known_derivations, free_derivation);