summaryrefslogtreecommitdiff
path: root/lib/xmalloc.c
Commit message (Collapse)AuthorAgeFilesLines
* xalloc: pacify -Wanalyzer-possible-null-argumentPaul Eggert2020-05-121-10/+21
| | | | | | | | Problem reported for GCC 10.1.0 by Bruno Haible in: https://lists.gnu.org/r/bug-gnulib/2020-05/msg00118.html * lib/xmalloc.c (HAVE_GNU_MALLOC, HAVE_GNU_REALLOC): New constants. (xmalloc): Suppress unnecessary check if HAVE_GNU_MALLOC. (xrealloc): Suppress unnecssary check if HAVE_GNU_REALLOC.
* maint: Run 'make update-copyright'Paul Eggert2019-12-311-1/+1
|
* xalloc: tune xzalloc for fresh allocationsPaul Eggert2019-12-171-3/+3
| | | | | | * lib/xmalloc.c (xzalloc): Use xcalloc rather than xmalloc+memset, because when the memory is freshly allocated from the OS via sbrk or mmap, calloc can avoid doing the memset.
* maint: Run 'make update-copyright'Paul Eggert2019-01-011-1/+1
|
* maint: Run 'make update-copyright'Paul Eggert2018-01-011-1/+1
|
* all: prefer https: URLsPaul Eggert2017-09-131-1/+1
|
* version-etc: new yearPaul Eggert2017-01-011-1/+1
| | | | | | | | | | * build-aux/gendocs.sh (version): * doc/gendocs_template: * doc/gendocs_template_min: * doc/gnulib.texi: * lib/version-etc.c (COPYRIGHT_YEAR): Update copyright dates by hand in templates and the like. * all files: Run 'make update-copyright'.
* xalloc: do not exceed PTRDIFF_MAXPaul Eggert2016-12-151-5/+5
| | | | | | * lib/xmalloc.c (xcalloc) [HAVE_GNU_CALLOC]: Do not omit xalloc_oversized check, since objects larger than PTRDIFF_MAX bytes have pointer-subtraction problems.
* version-etc: new yearPaul Eggert2016-01-011-1/+1
| | | | | | | | | | * build-aux/gendocs.sh (version): * doc/gendocs_template: * doc/gendocs_template_min: * doc/gnulib.texi: * lib/version-etc.c (COPYRIGHT_YEAR): Update copyright dates by hand in templates and the like. * all files: Run 'make update-copyright'.
* version-etc: new yearPaul Eggert2014-12-311-1/+1
| | | | | | * doc/gnulib.texi: * lib/version-etc.c (COPYRIGHT_YEAR): Update copyright date. * all files: Run 'make update-copyright'.
* maint: update copyrightEric Blake2014-01-011-1/+1
| | | | | | I ran 'make update-copyright'. Signed-off-by: Eric Blake <eblake@redhat.com>
* maint: update all copyright year number rangesEric Blake2013-01-011-1/+1
| | | | | | Run "make update-copyright". Compare to commit 1602f0a from last year. Signed-off-by: Eric Blake <eblake@redhat.com>
* xalloc: better 'inline'Paul Eggert2012-11-291-4/+2
| | | | | | | | | | | | * lib/xmalloc.c, lib/xalloc.h (XALLOC_INLINE): New macro. Replace all uses of 'static inline' with it. (static_inline): Remove. * lib/xalloc.h (xnmalloc, xnrealloc, x2nrealloc, xcharalloc): Let 'extern inline' do the work automatically, instead of doing it by hand. * m4/xalloc.m4 (gl_PREREQ_XALLOC, gl_PREREQ_XMALLOC): Remove. All uses removed. * modules/xalloc (Depends-on): Remove 'inline'. Add 'extern-inline'.
* maint: update all copyright year number rangesJim Meyering2012-01-011-1/+1
| | | | Run "make update-copyright".
* xmalloc: revert yesterday's regressionEric Blake2011-03-251-2/+2
| | | | | | | | * lib/xmalloc.c (xrealloc): Once again forward xrealloc(NULL,0) to realloc's underlying behavior (allowing allocation of zero-size objects, especially if malloc-gnu is also in use). Signed-off-by: Eric Blake <eblake@redhat.com>
* xmalloc: Do not leak if underlying realloc is C99 compatible.Paul Eggert2011-03-241-1/+9
| | | | | | * lib/xmalloc.c (xrealloc): If N is zero, call 'free' directly. This avoids a leak on C99-based systems. See <http://lists.gnu.org/archive/html/bug-gnulib/2011-03/msg00243.html>.
* maint: update almost all copyright ranges to include 2011Jim Meyering2011-01-011-3/+1
| | | | Run the new "make update-copyright" rule.
* Port to uClibc.Bruno Haible2010-11-201-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * lib/relocatable.c (find_shared_library_fullname): Treat uClibc like glibc. * lib/strerror_r.c: Likewise. * m4/arpa_inet_h.m4 (gl_HEADER_ARPA_INET): Likewise. * m4/duplocale.m4 (gl_FUNC_DUPLOCALE): Likewise. * m4/fsusage.m4 (gl_FILE_SYSTEM_USAGE): Likewise. * m4/glibc21.m4 (gl_GLIBC21): Likewise. * tests/test-sigaction.c (handler, main): Likewise. * lib/localename.c (gl_locale_name_thread_unsafe, HAVE_LOCALE_NULL): Treat uClibc like a non-glibc platform. * lib/propername.c (proper_name_utf8): Likewise. * lib/spawn.in.h: Likewise. * lib/striconv.c (mem_cd_iconv, str_cd_iconv, str_iconv): Likewise. * lib/striconveh.c (iconveh_open, iconv_carefully, iconv_carefully_1, mem_cd_iconveh_internal): Likewise. * lib/striconveha.c (mem_iconveha, str_iconveha): Likewise. * lib/string.in.h (memchr, memrchr, rawmemchr, strchrnul, strpbrk, strstr, strcasestr): Likewise. * lib/unicodeio.c (unicode_to_mb): Likewise. * m4/getdelim.m4 (gl_FUNC_GETDELIM): Likewise. * m4/getline.m4 (gl_FUNC_GETLINE): Likewise. * m4/glibc2.m4 (gt_GLIBC2): Likewise. * m4/iconv_open.m4 (gl_FUNC_ICONV_OPEN): Likewise. * m4/memmem.m4 (gl_FUNC_MEMMEM_SIMPLE, gl_FUNC_MEMMEM): Likewise. * m4/printf.m4 (gl_PRINTF_DIRECTIVE_A): Likewise. * m4/strcasestr.m4 (gl_FUNC_STRCASESTR_SIMPLE, gl_FUNC_STRCASESTR): Likewise. * m4/strstr.m4 (gl_FUNC_STRSTR_SIMPLE, gl_FUNC_STRSTR): Likewise. * m4/strtod.m4 (gl_FUNC_STRTOD): Likewise. * m4/sys_ioctl_h.m4 (gl_SYS_IOCTL_H): Likewise. * m4/sys_select_h.m4 (gl_HEADER_SYS_SELECT): Likewise. * m4/sys_socket_h.m4 (gl_HEADER_SYS_SOCKET): Likewise. * m4/sys_times_h.m4 (gl_SYS_TIMES_H): Likewise. * m4/unistd_h.m4 (gl_UNISTD_H): Likewise. * m4/wchar_h.m4 (gl_WCHAR_H): Likewise. * tests/test-getopt.h (OPTIND_MIN): Likewise. * tests/test-striconveha.c (main): Likewise. * doc/posix-functions/getdelim.texi: Mention an uClibc bug. * doc/posix-functions/getline.texi: Likewise. Reported by Mike Frysinger <vapier@gentoo.org>.
* Make the module 'calloc-gnu' work again on AIX and OSF/1.Bruno Haible2010-08-291-2/+2
|
* update nearly all FSF copyright year lists to include 2010Jim Meyering2010-01-011-3/+3
| | | | | Use the same procedure as for 2009, outlined in http://thread.gmane.org/gmane.comp.lib.gnulib.bugs/20081
* avoid gcc warnings about unused macro definitionsJim Meyering2009-03-121-5/+1
| | | | | | | | | | | | * lib/readtokens.c (STREQ): Remove unused definition. * lib/xmalloc.c (SIZE_MAX): Likewise. * lib/openat-die.c (N_): Likewise. * lib/mountlist.c (SIZE_MAX): Remove definition. Instead, include <stdint.h>. * lib/readutmp.c: Likewise. * modules/readutmp (Depends-on): Add stdint. * modules/mountlist (Depends-on): Add stdint. * lib/userspec.c (ISDIGIT): Move definition into #if block where used.
* Split xmemdup0 into its own module.Eric Blake2008-05-131-18/+0
| | | | | | | | | | | * modules/xmemdup0: New file. * lib/xmemdup0.h: Likewise. * lib/xmemdup0.c: Likewise. * MODULES.html.sh (Memory management functions): Add xmemdup0. * lib/xalloc.h (xmemdup0): Remove. * lib/xmalloc.c (xmemdup0): Likewise. Signed-off-by: Eric Blake <ebb9@byu.net>
* Add xmemdup0.Eric Blake2008-05-091-1/+19
| | | | | | | | * lib/xalloc.h (xmemdup0): New prototype and C++ typesafe implementation. * lib/xmalloc.c (xmemdup0): New C implementation. Signed-off-by: Eric Blake <ebb9@byu.net>
* Change copyright notice from GPLv2+ to GPLv3+.Bruno Haible2007-10-071-5/+4
|
* * lib/xalloc.h (XMALLOC, XNMALLOC, XZALLOC, XCALLOC): MovePaul Eggert2006-11-081-0/+4
| | | | | | | | | | | | | | | | | | definitions up, to avoid colliding with change below. (static_inline) [HAVE_INLINE]: New macro. (xnmalloc, xnrealloc, x2nrealloc, xcharalloc): Provide extern decls when !HAVE_INLINE. Do not define unless static_inline is defined, either by us or by xmalloc.c. Use static_inline rather than static inline. (XCALLOC): Optimize sizeof(T) = 1 case. * lib/xmalloc.c (static_inline) [!HAVE_INLINE]: New macro. 2006-11-07 Bruno Haible <bruno@clisp.org> * lib/xalloc.h (XNMALLOC): Restore optimization of sizeof(T) = 1 case. * m4/xalloc.m4 (gl_PREREQ_XALLOC): Require gl_INLINE instead of AC_C_INLINE. * modules/xalloc (Files): Add m4/inline.m4.
* * lib/xalloc.h (xnmalloc, xnrealloc, x2nrealloc): Now staticPaul Eggert2006-11-061-128/+7
| | | | | | | | | | | | | | | | | | | | | | | inline functions that are identical with the old xnmalloc_inline, xnrealloc_inline, x2nrealloc_inline of lib/xmalloc.c. This is so that we can avoid some unnecessary integer multiplications and divisions in the common case where the element size is known at compile time. (XNMALLOC) [HAVE_INLINE]: Remove special case, which is no longer needed. (xnboundedmalloc): Remove. (XMALLOC, XNMALLOC, XZALLOC, XCALLOC): Use lower-case letters for arguments, for consistency with rest of this header. (xcharalloc): Rewrite using XNMALLOC. * lib/xmalloc.c (xnmalloc_inline, xnmalloc, xnrealloc_inline): (xnrealloc, x2nrealloc_inline, x2nrealloc): Remove. The *_inline versions have been moved to lib/xalloc.h and renamed to be the non-*_inline versions. (xmalloc, xrealloc): Implement without reference to the xnmalloc and xnrealloc functions, since those functions are now inline and now call us. (x2realloc): Invoke x2realloc, not x2realloc_inline, to accommodate renaming described above.
* * _fpending.c: Include <config.h> unconditionally, since we noPaul Eggert2006-09-131-4/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | longer worry about uses that don't define HAVE_CONFIG_H. * acl.c, alloca.c, argmatch.c, atexit.c, backupfile.c: * basename.c, c-stack.c, c-strtod.c, calloc.c, canon-host.c: * canonicalize.c, chdir-long.c, chdir-safer.c, chown.c: * cloexec.c, close-stream.c, closeout.c, creat-safer.c: * cycle-check.c, diacrit.c, dirchownmod.c, dirfd.c, dirname.c: * dup-safer.c, dup2.c, error.c, euidaccess.c, exclude.c: * exitfail.c, fchmodat.c, fchown-stub.c, fd-safer.c: * file-type.c, fileblocks.c, filemode.c, filenamecat.c: * fnmatch.c, fopen-safer.c, fprintftime.c, free.c, fsusage.c: * ftruncate.c, fts-cycle.c, fts.c, full-write.c, gai_strerror.c: * getcwd.c, getdate.y, getdomainname.c, getgroups.c: * gethostname.c, gethrxtime.c, getloadavg.c, getlogin_r.c: * getndelim2.c, getnline.c, getopt.c, getopt1.c, getpass.c: * gettime.c, gettimeofday.c, getugroups.c, getusershell.c: * glob.c, group-member.c, hard-locale.c, hash-pjw.c, hash.c: * human.c, idcache.c, inet_ntop.c, inet_pton.c, inttostr.c: * isdir.c, lchown.c, linebuffer.c, long-options.c, lstat.c: * malloc.c, md5.c, memcasecmp.c, memchr.c, memcmp.c, memcoll.c: * memcpy.c, memmove.c, memrchr.c, mkancesdirs.c, mkdir-p.c: * mkdir.c, mkdirat.c, mkstemp-safer.c, mkstemp.c, modechange.c: * mountlist.c, nanosleep.c, obstack.c, open-safer.c: * openat-die.c, openat.c, pagealign_alloc.c, physmem.c: * pipe-safer.c, posixtm.c, posixver.c, putenv.c, quote.c: * quotearg.c, raise.c, readtokens.c, readtokens0.c, readutmp.c: * realloc.c, regex.c, rename.c, rmdir.c, rpmatch.c, safe-read.c: * same.c, save-cwd.c, savedir.c, setenv.c, settime.c, sha1.c: * sig2str.c, snprintf.c, strdup.c, strerror.c, strftime.c: * stripslash.c, strndup.c, strnlen.c, strpbrk.c, strtod.c: * strtoimax.c, strtol.c, strverscmp.c, tempname.c, time_r.c: * timegm.c, tmpfile-safer.c, unlinkdir.c, userspec.c, utime.c: * utimecmp.c, utimens.c, version-etc-fsf.c, version-etc.c: * xalloc-die.c, xgetcwd.c, xgethostname.c, xmalloc.c: * xmemcoll.c, xnanosleep.c, xreadlink.c, xstrtod.c: * xstrtoimax.c, xstrtol.c, xstrtoumax.c, yesno.c: Likewise.
* Use a consistent style for including <config.h>.Paul Eggert2005-09-191-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * __fpending.c, acl.c, argmatch.c, argp-help.c, argp-parse.c, argp-pvh.c, backupfile.c, basename.c, c-stack.c, calloc.c, check-version.c, cloexec.c, closeout.c, copy-file.c, creat-safer.c, cycle-check.c, dirfd.c, dirname.c, dup-safer.c, dup2.c, euidaccess.c, exclude.c, exitfail.c, fatal-signal.c, fd-safer.c, file-type.c, fileblocks.c, filemode.c, filenamecat.c, findprog.c, fnmatch.c, fopen-safer.c, free.c, fsusage.c, ftruncate.c, full-write.c, fwriteerror.c, getaddrinfo.c, getcwd.c, getdelim.c, getline.c, getlogin_r.c, getndelim2.c, getnline.c, getopt1.c, getpass.c, group-member.c, hard-locale.c, hash-pjw.c, hash.c, human.c, idcache.c, inet_ntop.c, isdir.c, long-options.c, malloc.c, memcasecmp.c, memcmp.c, memcoll.c, memcpy.c, memmove.c, mkdir-p.c, modechange.c, mountlist.c, open-safer.c, physmem.c, pipe-safer.c, pipe.c, poll.c, posixver.c, progname.c, progreloc.c, putenv.c, quote.c, quotearg.c, readline.c, readlink.c, realloc.c, regex.c, rename.c, rmdir.c, rpmatch.c, safe-read.c, same.c, save-cwd.c, savedir.c, sig2str.c, strcspn.c, strerror.c, stripslash.c, strncasecmp.c, strndup.c, strnlen.c, strnlen1.c, strsep.c, strstr.c, strtod.c, strtoimax.c, strtol.c, strverscmp.c, tempname.c, time_r.c, userspec.c, utimecmp.c, version-etc-fsf.c, version-etc.c, wait-process.c, xalloc-die.c, xgetcwd.c, xmalloc.c, xmemcoll.c, xnanosleep.c, xreadlink.c, xsetenv.c, xstrndup.c, xstrtoimax.c, xstrtol.c, xstrtoumax.c, yesno.c: Standardize inclusion of config.h. * __fpending.h, dirfd.h, getdate.h, human.h, inttostr.h: Removed inclusion of config.h from header files. * inttostr.c: Adjusted in-tree users. * timespec.h: Remove superfluous warning to include config.h. * atexit.c, chdir-long.c chown.c, fchown-stub.c, getgroups.c, gettimeofday.c, lchown.c, lstat.c, mkdir.c, mkstemp.c, nanosleep.c, openat.c, raise.c, readtokens0.c, readutmp.c, unlinkdir.c: Guard inclusion of config.h with HAVE_CONFIG_H.
* * xmalloc.c (HAVE_GNU_CALLOC): New constant.Paul Eggert2005-06-221-3/+15
| | | | (xcalloc): Use it to avoid needless tests.
* *** empty log message ***Paul Eggert2005-05-141-1/+1
|
* Rename xclone to xmemdup. Remove obsolete xalloc macros.Paul Eggert2004-10-051-2/+10
| | | | Remove xstrdup.c and move xstrdup implementation to xmalloc.c.
* Remove dependency of xalloc in exitfail, error, gettext.Paul Eggert2004-08-091-27/+1
|
* Remove dependency of hash and xalloc modules on the malloc and reallocPaul Eggert2004-06-011-12/+4
| | | | modules.
* (x2nrealloc_inline): Fix typos in comments: s/size/size_t/.Jim Meyering2003-11-221-5/+5
|
* New function xalloc_oversized.Paul Eggert2003-10-271-13/+3
|
* Add x2realloc, x2nrealloc. Port to C99 inline.Paul Eggert2003-10-271-6/+122
|
* Include <string.h>, for declarations of memset and memcpy.Jim Meyering2003-10-161-1/+2
|
* Revamp xalloc interface so that it can check for address arithmetic overflow.Paul Eggert2003-10-131-15/+62
|
* Use "exit.h" rather than rolling EXIT_FAILURE ourselves in each module.Paul Eggert2003-09-121-4/+1
|
* Remove K&R cruft.Paul Eggert2003-09-121-11/+3
|
* Sync with coreutils xalloc.h, xmalloc.c, xmemcoll.h, xmemcoll.c.Paul Eggert2003-07-221-5/+2
|
* Assume C89, so PARAMS isn't needed.Paul Eggert2003-06-181-2/+4
|
* Comment tweaks.Bruno Haible2002-11-211-2/+4
|
* Adjust to work with new autoconf macros, AC_FUNC_MALLOCJim Meyering2002-11-211-4/+4
| | | | and AC_FUNC_REALLOC: test #ifndef HAVE_MALLOC/HAVE_REALLOC.
* Include gettext.h instead of <libintl.h> with #ifdefs.Bruno Haible2002-11-051-9/+4
|
* [HAVE_DONE_WORKING_MALLOC_CHECK]: Enclose error-evokingJim Meyering2001-01-261-2/+2
| | | | | line in double quotes so that it evokes a better diagnostic. [HAVE_DONE_WORKING_REALLOC_CHECK]: Likewise.
* (xalloc_msg_memory_exhausted): Now char const[],Jim Meyering2000-08-071-4/+3
| | | | | not char *const and pointing to a constant array. (xrealloc): Comment fix.
* Use `virtual memory exhausted', not `Memory exhausted'.Jim Meyering2000-07-311-1/+1
|
* update copyright dateJim Meyering2000-07-091-1/+1
|
* (xalloc_die): Rename from xalloc_fail and update callers.Jim Meyering1999-09-261-5/+9
| | | | Use explicit exit to help avoid warnings.