forked from lattera/glibc
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Optimize xmalloc, xcalloc, xrealloc, and xstrdup
Add alloc_size attribute and apply consistently the malloc attribute to xmalloc, xcalloc, xrealloc, and xstrdup.
- Loading branch information
Showing
15 changed files
with
86 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,21 @@ | ||
2012-01-08 Ulrich Drepper <[email protected]> | ||
|
||
* include/sys/cdefs.h: Define __attribute_alloc_size. | ||
* catgets/gencat.c: Add alloc_size attribute and apply consistently | ||
the malloc attribute to xmalloc, xcalloc, xrealloc, and xstrdup. | ||
* elf/pldd.c: Likewise. | ||
* iconv/iconv_charmap.c: Likewise. | ||
* iconv/iconvconfig.c: Likewise. | ||
* iconv/strtab.c: Likewise. | ||
* locale/programs/locale.c: Likewise. | ||
* locale/programs/localedef.h: Likewise. | ||
* locale/programs/simple-hash.c: Likewise. | ||
* nscd/nscd.h: Likewise. | ||
* nss/makedb.c: Likewise. | ||
* sysdeps/generic/ldconfig.h: Likewise. | ||
* locale/programs/localedef.c: Remove xmalloc prototype. | ||
* nscd/mem.c: Remove xmalloc and xcalloc prototypes. | ||
|
||
2012-01-05 Paul Pluzhnikov <[email protected]> | ||
|
||
* stdio-common/vfscanf.c (_IO_vfscanf_internal): Use alloca when | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
/* Convert using charmaps and possibly iconv(). | ||
Copyright (C) 2001, 2005, 2006, 2008 Free Software Foundation, Inc. | ||
Copyright (C) 2001, 2005, 2006, 2008, 2012 Free Software Foundation, Inc. | ||
This file is part of the GNU C Library. | ||
Contributed by Ulrich Drepper <[email protected]>, 2001. | ||
|
@@ -33,8 +33,10 @@ | |
|
||
|
||
/* Prototypes for a few program-wide used functions. */ | ||
extern void *xmalloc (size_t __n); | ||
extern void *xcalloc (size_t __n, size_t __s); | ||
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); | ||
|
||
|
||
struct convtable | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
/* C string table handling. | ||
Copyright (C) 2000, 2001, 2005 Free Software Foundation, Inc. | ||
Copyright (C) 2000, 2001, 2005, 2012 Free Software Foundation, Inc. | ||
Written by Ulrich Drepper <[email protected]>, 2000. | ||
This program is free software; you can redistribute it and/or modify | ||
|
@@ -66,7 +66,8 @@ struct Strtab | |
static size_t ps; | ||
|
||
|
||
extern void *xmalloc (size_t n) __attribute_malloc__; | ||
extern void *xmalloc (size_t n) | ||
__attribute_malloc__ __attribute_alloc_size (1); | ||
|
||
/* Prototypes for our functions that are used from iconvconfig.c. If | ||
you change these, change also iconvconfig.c. */ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 <[email protected]>, 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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 <[email protected]>, 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 | ||
{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
/* Cache memory handling. | ||
Copyright (C) 2004, 2005, 2006, 2008, 2009 Free Software Foundation, Inc. | ||
Copyright (C) 2004-2006, 2008, 2009, 2012 Free Software Foundation, Inc. | ||
This file is part of the GNU C Library. | ||
Contributed by Ulrich Drepper <[email protected]>, 2004. | ||
|
@@ -35,11 +35,6 @@ | |
#include "nscd.h" | ||
|
||
|
||
/* Wrapper functions with error checking for standard functions. */ | ||
extern void *xmalloc (size_t n); | ||
extern void *xcalloc (size_t n, size_t s); | ||
|
||
|
||
static int | ||
sort_he (const void *p1, const void *p2) | ||
{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
/* Copyright (c) 1998-2001, 2003-2009, 2011 Free Software Foundation, Inc. | ||
/* Copyright (c) 1998-2001, 2003-2009, 2011, 2012 Free Software Foundation, Inc. | ||
This file is part of the GNU C Library. | ||
Contributed by Thorsten Kukuk <[email protected]>, 1998. | ||
|
@@ -201,9 +201,12 @@ extern gid_t old_gid; | |
/* Prototypes for global functions. */ | ||
|
||
/* Wrapper functions with error checking for standard functions. */ | ||
extern void *xmalloc (size_t n); | ||
extern void *xcalloc (size_t n, size_t s); | ||
extern void *xrealloc (void *o, size_t n); | ||
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); | ||
|
||
/* nscd.c */ | ||
extern void termination_handler (int signum) __attribute__ ((__noreturn__)); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
/* Copyright (C) 1999, 2000, 2002, 2003, 2007 Free Software Foundation, Inc. | ||
/* Copyright (C) 1999,2000,2002,2003,2007,2012 Free Software Foundation, Inc. | ||
This file is part of the GNU C Library. | ||
Contributed by Andreas Jaeger <[email protected]>, 1999. | ||
|
@@ -81,9 +81,12 @@ extern int opt_verbose; | |
extern int opt_format; | ||
|
||
/* 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__; | ||
|
||
#endif /* ! _LDCONFIG_H */ |