Mercurial > gnulib
changeset 34240:81dc39a99d12
allocator: New module.
* modules/allocator, lib/allocator.c: New files.
* lib/allocator.h (stdlib_allocator): New decl.
* lib/careadlinkat.c (_GL_USE_STDLIB_ALLOC, standard_allocator):
Remove. Do not include <stdlib.h>.
(careadlinkat): Use stdlib_allocator instead of rolling our own.
* modules/careadlinkat (Files): Remove lib/allocator.h.
(Depends-on): Add allocator.
author | Paul Eggert <eggert@cs.ucla.edu> |
---|---|
date | Fri, 08 Apr 2011 13:22:51 -0700 |
parents | 580a01d5b42c |
children | 490a007f5158 |
files | ChangeLog lib/allocator.c lib/allocator.h lib/careadlinkat.c modules/allocator modules/careadlinkat |
diffstat | 6 files changed, 41 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog Fri Apr 08 13:05:39 2011 -0700 +++ b/ChangeLog Fri Apr 08 13:22:51 2011 -0700 @@ -1,5 +1,14 @@ 2011-04-08 Paul Eggert <eggert@cs.ucla.edu> + allocator: New module. + * modules/allocator, lib/allocator.c: New files. + * lib/allocator.h (stdlib_allocator): New decl. + * lib/careadlinkat.c (_GL_USE_STDLIB_ALLOC, standard_allocator): + Remove. Do not include <stdlib.h>. + (careadlinkat): Use stdlib_allocator instead of rolling our own. + * modules/careadlinkat (Files): Remove lib/allocator.h. + (Depends-on): Add allocator. + stdlib: let modules use system malloc, realloc * lib/stdlib.in.h (malloc, realloc): Don't #define or add warnings if !_GL_USE_STDLIB_ALLOC.
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lib/allocator.c Fri Apr 08 13:22:51 2011 -0700 @@ -0,0 +1,5 @@ +#define _GL_USE_STDLIB_ALLOC 1 +#include <config.h> +#include "allocator.h" +#include <stdlib.h> +struct allocator const stdlib_allocator = { malloc, realloc, free, NULL };
--- a/lib/allocator.h Fri Apr 08 13:05:39 2011 -0700 +++ b/lib/allocator.h Fri Apr 08 13:22:51 2011 -0700 @@ -50,4 +50,7 @@ void (*die) (void); }; +/* An allocator using the stdlib functions and a null DIE function. */ +extern struct allocator const stdlib_allocator; + #endif
--- a/lib/careadlinkat.c Fri Apr 08 13:05:39 2011 -0700 +++ b/lib/careadlinkat.c Fri Apr 08 13:22:51 2011 -0700 @@ -18,7 +18,6 @@ /* Written by Paul Eggert, Bruno Haible, and Jim Meyering. */ -#define _GL_USE_STDLIB_ALLOC 1 #include <config.h> #include "careadlinkat.h" @@ -27,7 +26,6 @@ #include <errno.h> #include <limits.h> -#include <stdlib.h> #include <string.h> #include <unistd.h> @@ -53,11 +51,6 @@ } #endif -/* A standard allocator. For now, only careadlinkat needs this, but - perhaps it should be moved to the allocator module. */ -static struct allocator const standard_allocator = - { malloc, realloc, free, NULL }; - /* Assuming the current directory is FD, get the symbolic link value of FILENAME as a null-terminated string and put it into a buffer. If FD is AT_FDCWD, FILENAME is interpreted relative to the current @@ -90,7 +83,7 @@ char stack_buf[1024]; if (! alloc) - alloc = &standard_allocator; + alloc = &stdlib_allocator; if (! buffer_size) {
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/modules/allocator Fri Apr 08 13:22:51 2011 -0700 @@ -0,0 +1,22 @@ +Description: +Storage allocators. + +Files: +lib/allocator.h +lib/allocator.c + +Depends-on: + +configure.ac: + +Makefile.am: +lib_SOURCES += allocator.c + +Include: +"allocator.h" + +License: +LGPLv2+ + +Maintainer: +all