This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
[PATCH] _nl_load_domain: Use calloc instead of alloca
- From: fweimer at redhat dot com (Florian Weimer)
- To: libc-alpha at sourceware dot org
- Date: Mon, 19 Jun 2017 18:18:33 +0200
- Subject: [PATCH] _nl_load_domain: Use calloc instead of alloca
- Authentication-results: sourceware.org; auth=none
- Authentication-results: ext-mx08.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com
- Authentication-results: ext-mx08.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=fweimer at redhat dot com
- Dkim-filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 728C0C007AC5
- Dmarc-filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 728C0C007AC5
2017-06-19 Florian Weimer <fweimer@redhat.com>
* intl/loadmsgcat.c: Remove alloca support.
(_nl_load_domain): Use calloc instead of alloca.
diff --git a/intl/loadmsgcat.c b/intl/loadmsgcat.c
index 4dd75de..049fc88 100644
--- a/intl/loadmsgcat.c
+++ b/intl/loadmsgcat.c
@@ -32,29 +32,6 @@
#include <sys/types.h>
#include <sys/stat.h>
-#ifdef __GNUC__
-# undef alloca
-# define alloca __builtin_alloca
-# define HAVE_ALLOCA 1
-#else
-# ifdef _MSC_VER
-# include <malloc.h>
-# define alloca _alloca
-# else
-# if defined HAVE_ALLOCA_H || defined _LIBC
-# include <alloca.h>
-# else
-# ifdef _AIX
- #pragma alloca
-# else
-# ifndef alloca
-char *alloca ();
-# endif
-# endif
-# endif
-# endif
-#endif
-
#include <stdlib.h>
#include <string.h>
@@ -476,15 +453,6 @@ char *alloca ();
# define munmap(addr, len) __munmap (addr, len)
#endif
-/* For those losing systems which don't have `alloca' we have to add
- some additional code emulating it. */
-#ifdef HAVE_ALLOCA
-# define freea(p) /* nothing */
-#else
-# define alloca(n) malloc (n)
-# define freea(p) free (p)
-#endif
-
/* For systems that distinguish between text and binary I/O.
O_BINARY is usually declared in <fcntl.h>. */
#if !defined O_BINARY && defined _O_BINARY
@@ -982,9 +950,8 @@ _nl_load_domain (struct loaded_l10nfile *domain_file,
sysdep_segments = (const struct sysdep_segment *)
((char *) data
+ W (domain->must_swap, data->sysdep_segments_offset));
- sysdep_segment_values =
- (const char **)
- alloca (n_sysdep_segments * sizeof (const char *));
+ sysdep_segment_values = calloc
+ (n_sysdep_segments, sizeof (const char *));
for (i = 0; i < n_sysdep_segments; i++)
{
const char *name =
@@ -995,7 +962,7 @@ _nl_load_domain (struct loaded_l10nfile *domain_file,
if (!(namelen > 0 && name[namelen - 1] == '\0'))
{
- freea (sysdep_segment_values);
+ free (sysdep_segment_values);
goto invalid;
}
@@ -1046,7 +1013,7 @@ _nl_load_domain (struct loaded_l10nfile *domain_file,
if (sysdepref >= n_sysdep_segments)
{
/* Invalid. */
- freea (sysdep_segment_values);
+ free (sysdep_segment_values);
goto invalid;
}
@@ -1250,7 +1217,7 @@ _nl_load_domain (struct loaded_l10nfile *domain_file,
domain->trans_sysdep_tab = NULL;
}
- freea (sysdep_segment_values);
+ free (sysdep_segment_values);
}
else
{