From: Martin Mares Date: Mon, 10 Nov 2008 23:01:55 +0000 (+0100) Subject: Added xstrdup() to the common utility functions. X-Git-Tag: v3.1-alpha1~16 X-Git-Url: http://mj.ucw.cz/gitweb/?a=commitdiff_plain;h=d3f768e2d64cb61260ee6ab988c0423d64bb2ffa;hp=b69fad0df1a73aa4ce3fad2e1e26d3d4c72dfe41;p=pciutils.git Added xstrdup() to the common utility functions. --- 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