Fix for xml on mingw32

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@20736 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-Macdonald 2005-02-16 17:40:48 +00:00
parent 7308c55778
commit bfe4ac4b9c
2 changed files with 13 additions and 1 deletions

View file

@ -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 <rfm@gnu.org>

View file

@ -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;
}