summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Wellnhofer <wellnhofer@aevum.de>2017-11-09 13:42:33 +0100
committerNick Wellnhofer <wellnhofer@aevum.de>2017-11-09 15:30:15 +0100
commit71462a600608f5263e3907eef8d685571abeb1b9 (patch)
tree5b40036bb0d269b49388bef7e6e0f71b3d601315
parent28f52fe89dccf9c0a99a905522be8194230c4e77 (diff)
downloadlibxml2-71462a600608f5263e3907eef8d685571abeb1b9.tar.gz
Introduce xmlPosixStrdup and update xmlMemStrdup
Introduce xmlPosixStrdup, an internal strdup implementation matching the POSIX strdup type signature, and update xmlMemStrdup to use it. Thanks to Vlad Tsyrklevich for the initial patch.
-rw-r--r--globals.c22
1 files changed, 17 insertions, 5 deletions
diff --git a/globals.c b/globals.c
index e351b03f..20b43088 100644
--- a/globals.c
+++ b/globals.c
@@ -92,7 +92,7 @@ xmlStrdupFunc xmlMemStrdup = (xmlStrdupFunc) xmlMemoryStrdup;
*
* The variable holding the libxml free() implementation
*/
-xmlFreeFunc xmlFree = (xmlFreeFunc) free;
+xmlFreeFunc xmlFree = free;
/**
* xmlMalloc:
* @size: the size requested in bytes
@@ -101,7 +101,7 @@ xmlFreeFunc xmlFree = (xmlFreeFunc) free;
*
* Returns a pointer to the newly allocated block or NULL in case of error
*/
-xmlMallocFunc xmlMalloc = (xmlMallocFunc) malloc;
+xmlMallocFunc xmlMalloc = malloc;
/**
* xmlMallocAtomic:
* @size: the size requested in bytes
@@ -112,7 +112,7 @@ xmlMallocFunc xmlMalloc = (xmlMallocFunc) malloc;
*
* Returns a pointer to the newly allocated block or NULL in case of error
*/
-xmlMallocFunc xmlMallocAtomic = (xmlMallocFunc) malloc;
+xmlMallocFunc xmlMallocAtomic = malloc;
/**
* xmlRealloc:
* @mem: an already allocated block of memory
@@ -122,7 +122,19 @@ xmlMallocFunc xmlMallocAtomic = (xmlMallocFunc) malloc;
*
* Returns a pointer to the newly reallocated block or NULL in case of error
*/
-xmlReallocFunc xmlRealloc = (xmlReallocFunc) realloc;
+xmlReallocFunc xmlRealloc = realloc;
+/**
+ * xmlPosixStrdup
+ * @cur: the input char *
+ *
+ * a strdup implementation with a type signature matching POSIX
+ *
+ * Returns a new xmlChar * or NULL
+ */
+static char *
+xmlPosixStrdup(const char *cur) {
+ return((char*) xmlCharStrdup(cur));
+}
/**
* xmlMemStrdup:
* @str: a zero terminated string
@@ -131,7 +143,7 @@ xmlReallocFunc xmlRealloc = (xmlReallocFunc) realloc;
*
* Returns the copy of the string or NULL in case of error
*/
-xmlStrdupFunc xmlMemStrdup = (xmlStrdupFunc) xmlStrdup;
+xmlStrdupFunc xmlMemStrdup = xmlPosixStrdup;
#endif /* DEBUG_MEMORY_LOCATION || DEBUG_MEMORY */
#include <libxml/threads.h>