]> git.ipfire.org Git - thirdparty/pciutils.git/commitdiff
Added xstrdup() to the common utility functions.
authorMartin Mares <mj@ucw.cz>
Mon, 10 Nov 2008 23:01:55 +0000 (00:01 +0100)
committerMartin Mares <mj@ucw.cz>
Mon, 10 Nov 2008 23:01:55 +0000 (00:01 +0100)
common.c
pciutils.h

index ed39b87148f6c726178f206f460c39c39975c56f..8ea52fa6d7b5398d2ff4a1c90cd9faa10ca410a7 100644 (file)
--- a/common.c
+++ b/common.c
@@ -44,6 +44,15 @@ xrealloc(void *ptr, unsigned int howmuch)
   return p;
 }
 
+char *
+xstrdup(char *str)
+{
+  int len = strlen(str) + 1;
+  char *copy = xmalloc(len);
+  memcpy(copy, str, len);
+  return copy;
+}
+
 static void
 set_pci_method(struct pci_access *pacc, char *arg)
 {
index 67b586fb57154831c25a6a2594c0636553f06923..1f347a588d4398be3b7e11b264d29d65e0027363 100644 (file)
@@ -20,6 +20,7 @@ extern const char program_name[];
 void die(char *msg, ...) NONRET PCI_PRINTF(1,2);
 void *xmalloc(unsigned int howmuch);
 void *xrealloc(void *ptr, unsigned int howmuch);
+char *xstrdup(char *str);
 int parse_generic_option(int i, struct pci_access *pacc, char *optarg);
 
 #ifdef PCI_HAVE_PM_INTEL_CONF