[Mono-list] String Marshalling for P/Invoke

Gonzalo Paniagua Javier gonzalo@ximian.com
09 Jan 2003 17:25:57 +0100


El jue, 09-01-2003 a las 11:25, Michael Meeks escribió:
> 	Hard to say what's best to do; short of using the native free / malloc
> for everything [ loosing g_new0 etc. ]. I guess the current solution
> works fine as long as no-one does funnies with the glib allocator [
> which tends to break software en-masse anyway; people g_freeing
> xmlAlloc-ated string, people xmlFree-ing, g_strdup'd strings etc. etc.
> ].
[Semi-OT]
Btw, libxml2 allows:

	xmlMemGet (&old_free,
		   &old_malloc,
		   &old_realloc,
		   &old_strdup);

	xmlMemSetup (g_free,
		     (xmlMallocFunc) g_malloc,
		     (xmlReallocFunc) g_realloc,
		     g_strdup);

	...your code...
	...restore old_ones...

-Gonzalo