aboutsummaryrefslogtreecommitdiff
path: root/intl/localealias.c
diff options
context:
space:
mode:
Diffstat (limited to 'intl/localealias.c')
-rw-r--r--intl/localealias.c23
1 files changed, 16 insertions, 7 deletions
diff --git a/intl/localealias.c b/intl/localealias.c
index d2b5ae8895..57c693dcde 100644
--- a/intl/localealias.c
+++ b/intl/localealias.c
@@ -16,6 +16,13 @@
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
+/* Tell glibc's <string.h> to provide a prototype for mempcpy().
+ This must come before <config.h> because <config.h> may include
+ <features.h>, and once <features.h> has been included, it's too late. */
+#ifndef _GNU_SOURCE
+# define _GNU_SOURCE 1
+#endif
+
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
@@ -53,9 +60,6 @@ void free ();
#endif
#if defined HAVE_STRING_H || defined _LIBC
-# ifndef _GNU_SOURCE
-# define _GNU_SOURCE 1
-# endif
# include <string.h>
#else
# include <strings.h>
@@ -158,7 +162,7 @@ static size_t maxmap;
/* Prototypes for local functions. */
static size_t read_alias_file PARAMS ((const char *fname, int fname_len))
internal_function;
-static void extend_alias_table PARAMS ((void));
+static int extend_alias_table PARAMS ((void));
static int alias_compare PARAMS ((const struct alias_map *map1,
const struct alias_map *map2));
@@ -326,7 +330,11 @@ read_alias_file (fname, fname_len)
*cp++ = '\0';
if (nmap >= maxmap)
- extend_alias_table ();
+ if (__builtin_expect (extend_alias_table (), 0))
+ {
+ FREE_BLOCKS (block_list);
+ return added;
+ }
alias_len = strlen (alias) + 1;
value_len = strlen (value) + 1;
@@ -374,7 +382,7 @@ read_alias_file (fname, fname_len)
}
-static void
+static int
extend_alias_table ()
{
size_t new_size;
@@ -385,10 +393,11 @@ extend_alias_table ()
* sizeof (struct alias_map)));
if (new_map == NULL)
/* Simply don't extend: we don't have any more core. */
- return;
+ return -1;
map = new_map;
maxmap = new_size;
+ return 0;
}