]> git.ipfire.org Git - thirdparty/pciutils.git/commitdiff
Adjust prototypes of xmalloc(), xrealloc() and xstrdup()
authorMartin Mares <mj@ucw.cz>
Sat, 17 Mar 2018 11:39:00 +0000 (12:39 +0100)
committerMartin Mares <mj@ucw.cz>
Sat, 17 Mar 2018 11:39:00 +0000 (12:39 +0100)
SylixOS defines its own versions of these functions in its standard
library, which collide with ours. However, their prototypes make
more sense, because they follow the prototypes of the non-x versions
in the C standard, so there is no harm in following them.

common.c
pciutils.h

index 8ea52fa6d7b5398d2ff4a1c90cd9faa10ca410a7..9cd72bee122dacc6b13248215c0f225bbd7413b3 100644 (file)
--- a/common.c
+++ b/common.c
@@ -1,7 +1,7 @@
 /*
  *     The PCI Utilities -- Common Functions
  *
- *     Copyright (c) 1997--2008 Martin Mares <mj@ucw.cz>
+ *     Copyright (c) 1997--2016 Martin Mares <mj@ucw.cz>
  *
  *     Can be freely distributed and used under the terms of the GNU GPL.
  */
@@ -27,25 +27,25 @@ die(char *msg, ...)
 }
 
 void *
-xmalloc(unsigned int howmuch)
+xmalloc(size_t howmuch)
 {
   void *p = malloc(howmuch);
   if (!p)
-    die("Unable to allocate %d bytes of memory", howmuch);
+    die("Unable to allocate %d bytes of memory", (int) howmuch);
   return p;
 }
 
 void *
-xrealloc(void *ptr, unsigned int howmuch)
+xrealloc(void *ptr, size_t howmuch)
 {
   void *p = realloc(ptr, howmuch);
   if (!p)
-    die("Unable to allocate %d bytes of memory", howmuch);
+    die("Unable to allocate %d bytes of memory", (int) howmuch);
   return p;
 }
 
 char *
-xstrdup(char *str)
+xstrdup(const char *str)
 {
   int len = strlen(str) + 1;
   char *copy = xmalloc(len);
index e433e6beea547b04e2a4ba2baf095a7e1235b9b7..1de2b01fcd7315faf367d967d0995c785a6c37a2 100644 (file)
@@ -1,7 +1,7 @@
 /*
  *     The PCI Utilities -- Declarations
  *
- *     Copyright (c) 1997--2008 Martin Mares <mj@ucw.cz>
+ *     Copyright (c) 1997--2016 Martin Mares <mj@ucw.cz>
  *
  *     Can be freely distributed and used under the terms of the GNU GPL.
  */
@@ -20,9 +20,9 @@
 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);
+void *xmalloc(size_t howmuch);
+void *xrealloc(void *ptr, size_t howmuch);
+char *xstrdup(const char *str);
 int parse_generic_option(int i, struct pci_access *pacc, char *optarg);
 
 #ifdef PCI_HAVE_PM_INTEL_CONF