xmemdup.c: New xmemdup function.
authorJeff Garzik <jgarzik@pobox.com>
Wed, 8 Sep 1999 08:19:52 +0000 (08:19 +0000)
committerJeff Law <law@gcc.gnu.org>
Wed, 8 Sep 1999 08:19:52 +0000 (02:19 -0600)
* xmemdup.c:  New xmemdup function.
* Makefile.in, makefile.vms, vmsbuild.com:  Use xmemdup.[co].

From-SVN: r29199

libiberty/ChangeLog
libiberty/Makefile.in
libiberty/makefile.vms
libiberty/vmsbuild.com
libiberty/xmemdup.c [new file with mode: 0644]

index 317e9da9313e405976025149a4cd790da7a30acd..77f42efd8085fbcb6b389d603c4e2dd551b06056 100644 (file)
@@ -1,3 +1,8 @@
+1999-09-07  Jeff Garzik  <jgarzik@pobox.com>
+
+       * xmemdup.c: New xmemdup function.
+       * Makefile.in, makefile.vms, vmsbuild.com:  Use xmemdup.[co].
+
 Tue Sep  7 23:32:18 1999  Linas Vepstas  <linas@linas.org>
 
         * config.table: Add openedition target.
index 001a714cd467d05141089038c28369e192ce22a4..adaf8a6a98c286bb161e3354749ef708698ac3a2 100644 (file)
@@ -129,14 +129,14 @@ CFILES = asprintf.c alloca.c argv.c atexit.c basename.c bcmp.c bcopy.c \
        spaces.c splay-tree.c strcasecmp.c strncasecmp.c strchr.c strdup.c \
        strerror.c strrchr.c strsignal.c strstr.c strtod.c strtol.c strtoul.c \
        tmpnam.c vasprintf.c vfork.c vfprintf.c vprintf.c vsprintf.c \
-       waitpid.c xatexit.c xexit.c xmalloc.c xstrdup.c xstrerror.c
+       waitpid.c xatexit.c xexit.c xmalloc.c xmemdup.c xstrdup.c xstrerror.c
 
 # These are always included in the library.
 REQUIRED_OFILES = argv.o choose-temp.o concat.o cplus-dem.o \
   fdmatch.o fnmatch.o getopt.o getopt1.o getpwd.o getruntime.o hex.o \
   floatformat.o objalloc.o obstack.o pexecute.o spaces.o \
   splay-tree.o strerror.o strsignal.o xatexit.o xexit.o xmalloc.o \
-  xstrdup.o xstrerror.o
+  xmemdup.o xstrdup.o xstrerror.o
 
 $(TARGETLIB): $(REQUIRED_OFILES) $(EXTRA_OFILES) $(LIBOBJS) $(ALLOCA)
        rm -f $(TARGETLIB)
@@ -270,5 +270,6 @@ strsignal.o: config.h $(INCDIR)/libiberty.h
 xatexit.o: $(INCDIR)/libiberty.h
 xexit.o: $(INCDIR)/libiberty.h
 xmalloc.o: $(INCDIR)/libiberty.h
+xmemdup.o: config.h $(INCDIR)/libiberty.h
 xstrdup.o: config.h $(INCDIR)/libiberty.h
 xstrerror.o: config.h $(INCDIR)/libiberty.h
index b61b51290daff41e02d33fee173cd56b0e0821fd..6a7dd45718ee8c8b55357a716d690dbefacc0890 100644 (file)
@@ -10,7 +10,7 @@
 OBJS=bcopy.obj,bcmp.obj,getopt.obj,obstack.obj,xexit.obj,xmalloc.obj,hex.obj,\
    getopt1.obj,cplus-dem.obj,strncasecmp.obj,strcasecmp.obj,strdup.obj,\
    concat.obj,getruntime.obj,getpagesize.obj,alloca.obj,xstrerror.obj,\
-   xstrdup.obj,xatexit.obj,choose-temp.obj,fnmatch.obj,objalloc.obj
+   xmemdup.obj,xstrdup.obj,xatexit.obj,choose-temp.obj,fnmatch.obj,objalloc.obj
 
 ifeq ($(CC),gcc)
 CFLAGS=/include=([],[-.include])
index 4fede380bfd6d39a4741c39cdbb3654d0b44475d..497ea8974f2b9f013f2c0182d73f0cd0a9335454 100644 (file)
@@ -15,7 +15,7 @@ $! manually copied from Makefile.in
 $ REQUIRED_OFILES = "argv.o basename.o choose-temp.o concat.o cplus-dem.o "-
        + "fdmatch.o fnmatch.o getopt.o getopt1.o getruntime.o hex.o "-
        + "floatformat.o objalloc.o obstack.o spaces.o strerror.o strsignal.o "-
-       + "xatexit.o xexit.o xmalloc.o xstrdup.o xstrerror.o"
+       + "xatexit.o xexit.o xmalloc.o xmemdup.o xstrdup.o xstrerror.o"
 $! anything not caught by link+search of dummy.* should be added here
 $ EXTRA_OFILES = ""
 $!
diff --git a/libiberty/xmemdup.c b/libiberty/xmemdup.c
new file mode 100644 (file)
index 0000000..8e82469
--- /dev/null
@@ -0,0 +1,20 @@
+/* xmemdup.c -- Duplicate a memory buffer, using xcalloc.
+   This trivial function is in the public domain.
+   Jeff Garzik, September 1999.  */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+#include "ansidecl.h"
+#include "libiberty.h"
+
+PTR
+xmemdup (input, copy_size, alloc_size)
+  const PTR input;
+  size_t copy_size;
+  size_t alloc_size;
+{
+  PTR output = xcalloc (1, alloc_size);
+  memcpy (output, input, copy_size);
+  return output;
+}