From d3f768e2d64cb61260ee6ab988c0423d64bb2ffa Mon Sep 17 00:00:00 2001 From: Martin Mares Date: Tue, 11 Nov 2008 00:01:55 +0100 Subject: [PATCH] Added xstrdup() to the common utility functions. --- common.c | 9 +++++++++ pciutils.h | 1 + 2 files changed, 10 insertions(+) diff --git a/common.c b/common.c index ed39b87..8ea52fa 100644 --- 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) { diff --git a/pciutils.h b/pciutils.h index 67b586f..1f347a5 100644 --- a/pciutils.h +++ b/pciutils.h @@ -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 -- 2.39.2