summary refs log tree commit diff
path: root/locale/programs
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@gmail.com>2012-01-08 21:19:43 -0500
committerUlrich Drepper <drepper@gmail.com>2012-01-08 21:19:43 -0500
commitec09c1c410d40386ec3e5d2d82fc5c378b4b2681 (patch)
tree2189714f7efcfc502ddef885c7c1d541eae6684c /locale/programs
parentaebae0537dcb408100b88c6b7647a7e858c43237 (diff)
downloadglibc-ec09c1c410d40386ec3e5d2d82fc5c378b4b2681.tar.gz
glibc-ec09c1c410d40386ec3e5d2d82fc5c378b4b2681.tar.xz
glibc-ec09c1c410d40386ec3e5d2d82fc5c378b4b2681.zip
Optimize xmalloc, xcalloc, xrealloc, and xstrdup
Add alloc_size attribute and apply consistently the malloc attribute
to xmalloc, xcalloc, xrealloc, and xstrdup.
Diffstat (limited to 'locale/programs')
-rw-r--r--locale/programs/locale.c5
-rw-r--r--locale/programs/localedef.c3
-rw-r--r--locale/programs/localedef.h13
-rw-r--r--locale/programs/simple-hash.c8
4 files changed, 16 insertions, 13 deletions
diff --git a/locale/programs/locale.c b/locale/programs/locale.c
index 579094d9a4..2cd4be8fb6 100644
--- a/locale/programs/locale.c
+++ b/locale/programs/locale.c
@@ -44,8 +44,9 @@
 #include "charmap-dir.h"
 #include "../locarchive.h"
 
-extern void *xmalloc (size_t __n);
-extern char *xstrdup (const char *__str);
+extern void *xmalloc (size_t n)
+  __attribute_malloc__ __attribute_alloc_size (1);
+extern char *xstrdup (const char *) __attribute_malloc__;
 
 #define ARCHIVE_NAME LOCALEDIR "/locale-archive"
 
diff --git a/locale/programs/localedef.c b/locale/programs/localedef.c
index aa59444e2a..75905f9c38 100644
--- a/locale/programs/localedef.c
+++ b/locale/programs/localedef.c
@@ -169,9 +169,6 @@ static struct argp argp =
 };
 
 
-/* Prototypes for global functions.  */
-extern void *xmalloc (size_t __n);
-
 /* Prototypes for local functions.  */
 static void error_print (void);
 static const char *construct_output_path (char *path);
diff --git a/locale/programs/localedef.h b/locale/programs/localedef.h
index bdff9e6f28..ac1cae54d4 100644
--- a/locale/programs/localedef.h
+++ b/locale/programs/localedef.h
@@ -1,5 +1,5 @@
 /* General definitions for localedef(1).
-   Copyright (C) 1998,1999,2000,2001,2002,2005 Free Software Foundation, Inc.
+   Copyright (C) 1998-2002,2005,2012 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998.
 
@@ -121,10 +121,13 @@ extern const char *alias_file;
 
 
 /* Prototypes for a few program-wide used functions.  */
-extern void *xmalloc (size_t __n);
-extern void *xcalloc (size_t __n, size_t __size);
-extern void *xrealloc (void *__p, size_t __n);
-extern char *xstrdup (const char *__str);
+extern void *xmalloc (size_t n)
+  __attribute_malloc__ __attribute_alloc_size (1);
+extern void *xcalloc (size_t n, size_t s)
+  __attribute_malloc__ __attribute_alloc_size (1, 2);
+extern void *xrealloc (void *o, size_t n)
+  __attribute_malloc__ __attribute_alloc_size (2);
+extern char *xstrdup (const char *) __attribute_malloc__;
 
 
 /* Wrapper to switch LC_CTYPE back to the locale specified in the
diff --git a/locale/programs/simple-hash.c b/locale/programs/simple-hash.c
index b9cc237e49..573f7e424d 100644
--- a/locale/programs/simple-hash.c
+++ b/locale/programs/simple-hash.c
@@ -1,5 +1,5 @@
 /* Implement simple hashing table with string based keys.
-   Copyright (C) 1994-1997,2000,2001,2002,2005 Free Software Foundation, Inc.
+   Copyright (C) 1994-1997,2000-2002,2005,2012 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Written by Ulrich Drepper <drepper@gnu.ai.mit.edu>, October 1994.
 
@@ -53,8 +53,10 @@
 #define hashval_t uint32_t
 #include "hashval.h"
 
-extern void *xmalloc (size_t __n);
-extern void *xcalloc (size_t __n, size_t __m);
+extern void *xmalloc (size_t n)
+  __attribute_malloc__ __attribute_alloc_size (1);
+extern void *xcalloc (size_t n, size_t s)
+  __attribute_malloc__ __attribute_alloc_size (1, 2);
 
 typedef struct hash_entry
 {