aboutsummaryrefslogtreecommitdiff
path: root/src/mem.c
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2011-11-13 15:28:04 +0000
committerSergey Poznyakoff <gray@gnu.org.ua>2011-11-13 15:28:04 +0000
commitfd714cdcec660f915917edd239324e7544daa234 (patch)
tree9bcf5029b60bf482a2d13b7b2a2194b4a6f7c6f5 /src/mem.c
parent5d14e2acfec6f5ded1c88c7912224157a79be351 (diff)
downloadgdbm-fd714cdcec660f915917edd239324e7544daa234.tar.gz
gdbm-fd714cdcec660f915917edd239324e7544daa234.tar.bz2
Implement new dump format. Add new utilities: gdbm_dump and gdbm_load.
* configure.ac (AC_CHECK_HEADERS): Don't check for files that must always be present. Check for getopt.h. (AC_CHECK_FUNCS): Add getopt_long * src/systems.h: Include useless #if's. * src/flatfile.c: Split into two files: * src/gdbmexp.c: ... this and ... * src/gdbmimp.c: .., this * src/mem.c: New file. * src/base64.c: New file. * src/gdbm_dump.c: New file. * src/gdbm_load.c: New file. * src/gdbmapp.h: New file. * src/gdbmdump.c: New file. * src/gdbmload.c: New file. * src/parseopt.c: New file. * src/progname.c: New file. * src/.cvsignore: Update. * src/Makefile.am (libgdbm_la_SOURCES): Add new files. (noinst_LIBRARIES): New variable. Build libgdbmapp.a. (libgdbmapp_a_SOURCES): New variable. (bin_PROGRAMS): Add gdbm_load and gdbm_dump (testgdbm_LDADD, gdbm_load_LDADD) (gdbm_dump_LDADD): Add ./libgdbmapp.a * src/gdbm.h.in: Include <stdio.h> (gdbm_export_to_file) (gdbm_import_from_file): New prototypes. (GDBM_DUMP_FMT_BINARY,GDBM_DUMP_FMT_ASCII): New constants. (gdbm_dump,gdbm_load) (gdbm_dump_to_file,gdbm_load_from_file): New prototypes. (GDBM_NO_DBNAME): New error code. (_GDBM_MAX_ERRNO): Update. * src/gdbmdefs.h (_GDBM_MAX_DUMP_LINE_LEN): New constant. * src/gdbmerrno.c (gdbm_errlist): Add entry for GDBM_NO_DBNAME. * src/proto.h (_gdbm_base64_encode,_gdbm_base64_decode) (_gdbm_load,_gdbm_dump): New prototypes. * src/testgdbm.c: Use gdbmapp interface for option parsing. * export/export.c: Include gdbmexp.c * export/.cvsignore: Update. * doc/gdbm.texinfo: Update.
Diffstat (limited to 'src/mem.c')
-rw-r--r--src/mem.c74
1 files changed, 74 insertions, 0 deletions
diff --git a/src/mem.c b/src/mem.c
new file mode 100644
index 0000000..34c55f4
--- /dev/null
+++ b/src/mem.c
@@ -0,0 +1,74 @@
+/* This file is part of GDBM, the GNU data base manager.
+ Copyright (C) 2011 Free Software Foundation, Inc.
+
+ GDBM is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3, or (at your option)
+ any later version.
+
+ GDBM is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with GDBM. If not, see <http://www.gnu.org/licenses/>. */
+
+# include "autoconf.h"
+# include "gdbm.h"
+# include "gdbmapp.h"
+# include "gdbmdefs.h"
+
+void
+ealloc_die ()
+{
+ error ("%s", strerror (ENOMEM));
+ exit (1);
+}
+
+void *
+emalloc (size_t size)
+{
+ void *p = malloc (size);
+ if (!p)
+ ealloc_die ();
+ return p;
+}
+
+void *
+erealloc (void *ptr, size_t size)
+{
+ void *newptr = realloc (ptr, size);
+ if (!newptr)
+ ealloc_die ();
+ return newptr;
+}
+
+void *
+ecalloc (size_t nmemb, size_t size)
+{
+ void *p = calloc (nmemb, size);
+ if (!p)
+ ealloc_die ();
+ return p;
+}
+
+void *
+ezalloc (size_t size)
+{
+ return ecalloc (1, size);
+}
+
+char *
+estrdup (char *str)
+{
+ char *p;
+
+ if (!str)
+ return NULL;
+ p = emalloc (strlen (str) + 1);
+ strcpy (p, str);
+ return p;
+}
+
+

Return to:

Send suggestions and report system problems to the System administrator.