From c66073233b7fb255fdd9d5e7e4fc9273edb321f5 Mon Sep 17 00:00:00 2001 From: CaS Date: Wed, 16 Feb 2005 17:40:48 +0000 Subject: [PATCH] Fix for xml on mingw32 git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@20736 72102866-910b-0410-8b05-ffd578937521 --- ChangeLog | 3 +++ Source/Additions/GSXML.m | 11 ++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 12bbe14ff..1022f0b1a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -6,6 +6,9 @@ requires iconv (which it usually will on a system where iconv is not built into the standard c library). * confingure: Regenerate + * Source/Additions/GSXML.m: Set memory allocation functions to be + used by libxml2, so we can use objc_free() to release strings returned + by the library, and avoid linker problem with xmlFree() on mingw. 2005-02-15 08:00 Richard Frith-Macdonald diff --git a/Source/Additions/GSXML.m b/Source/Additions/GSXML.m index 2d000f018..1af4d0fba 100644 --- a/Source/Additions/GSXML.m +++ b/Source/Additions/GSXML.m @@ -124,12 +124,21 @@ static BOOL cacheDone = NO; @end #endif +static char * objc_strdup(const char *from) +{ + unsigned len = (from == 0) ? 1 : (strlen(from) + 1); + char *to = objc_malloc(len); + strcpy(to, from); + return to; +} + static void setupCache() { if (cacheDone == NO) { cacheDone = YES; + xmlMemSetup(objc_free, objc_malloc, objc_realloc, objc_strdup); #if HAVE_LIBXML_SAX2_H xmlDefaultSAXHandlerInit(); @@ -376,7 +385,7 @@ static NSMapTable *attrNames = 0; if (buf != 0 && length > 0) { string = UTF8StrLen(buf, length); - xmlFree(buf); + objc_free(buf); } return string; }