|
|
| version 1.152.2.19.2.6, 2003/03/27 17:05:32 | version 1.152.2.19.2.15, 2003/04/09 08:40:25 |
|---|---|
| Line 22 extern "C" { | Line 22 extern "C" { |
| #include "pa_sapi.h" | #include "pa_sapi.h" |
| #include "pa_threads.h" | #include "pa_threads.h" |
| // defines | |
| #define PA_DEBUG_XML_GC_MEMORY | |
| // globals | |
| short hex_value[0x100]; | short hex_value[0x100]; |
| #ifdef XML | #ifdef XML |
| Line 71 public: | Line 78 public: |
| thread_id=0; | thread_id=0; |
| buf[used=0]=0; | buf[used=0]=0; |
| } | } |
| const char* get_and_reset() { | const char* getnd_reset() { |
| char* result=new(PointerFreeGC) char[used+1]; | char* result=new(PointerFreeGC) char[used+1]; |
| memcpy(result, buf, used+1); | memcpy(result, buf, used+1); |
| reset(); | reset(); |
| Line 132 const char* xmlGenericErrors() { | Line 139 const char* xmlGenericErrors() { |
| if(!p) // no errors for our thread_id registered | if(!p) // no errors for our thread_id registered |
| return 0; | return 0; |
| return p->get_and_reset(); | return p->getnd_reset(); |
| } | } |
| /** | /** |
| Line 221 void pa_globals_destroy(void *) { | Line 228 void pa_globals_destroy(void *) { |
| #ifdef XML | #ifdef XML |
| char *pa_GC_strdup(const char *s) { | static char *pa_GC_strdup(const char *s) { |
| if(!s) | if(!s) |
| return 0; | return 0; |
| size_t size=strlen(s)+1; | size_t size=strlen(s)+1; |
| char *result=(char *)GC_MALLOC_ATOMIC(size); | char *result=(char *)GC_malloc_atomic(size); |
| memcpy(result, s, size); | memcpy(result, s, size); |
| return result; | return result; |
| } | } |
| #endif | #endif |
| /// @test hint on one should call this for each thread xmlSubstituteEntitiesDefault(1); | void pa_CORD_oom_fn(void) { |
| SAPI::abort("out of memory (while expanding string)"); | |
| } | |
| /** | |
| @todo gc: pcre: substitute pcre_malloc &co | |
| @todo gc: libltdl: substitute lt_dlmalloc & co | |
| @todo gc: figure out how to substitute glib memory allocator | |
| */ | |
| static void gc_substitute_memory_management_functions() { | |
| // in libxml & libxslt | |
| #ifdef XML | |
| // asking to use GC memory | |
| xmlMemSetup( | |
| /*xmlFreeFunc */pa_gc_free, | |
| /*xmlMallocFunc */pa_gc_malloc, | |
| /*xmlReallocFunc */pa_gc_realloc, | |
| /*xmlStrdupFunc */pa_GC_strdup); | |
| #endif | |
| CORD_oom_fn=pa_CORD_oom_fn; | |
| } | |
| /** | |
| @test hint on one should call this for each thread xmlSubstituteEntitiesDefault(1); | |
| */ | |
| void pa_globals_init() { | void pa_globals_init() { |
| // in various libraries | |
| gc_substitute_memory_management_functions(); | |
| // hex value | // hex value |
| setup_hex_value(); | setup_hex_value(); |
| #ifdef XML | #ifdef XML |
| // initializing xml libs | // initializing xml libs |
| xmlMemSetup(/*xmlFreeFunc */GC_free, | |
| /*xmlMallocFunc */GC_malloc, | |
| /*xmlReallocFunc */GC_realloc, | |
| /*xmlStrdupFunc */pa_GC_strdup); | |
| /* First I get a DOMImplementation reference */ | /* First get a DOMImplementation reference */ |
| domimpl = gdome_di_mkref (); | domimpl = gdome_di_mkref (); |
| /* | /* |
| * Register the EXSLT extensions and the test module | * Register the EXSLT extensions and the test module |
| Line 298 void pa_globals_init() { | Line 328 void pa_globals_init() { |
| #endif | #endif |
| } | } |
| #if defined(XML) && defined(_MSC_VER) | #ifdef _MSC_VER |
| #ifndef PA_DEBUG_DISABLE_GC | |
| # define GC_LIB "/parser3project/win32/gc" | |
| # ifdef _DEBUG | |
| # pragma comment(lib, GC_LIB "/Debug/gc.lib") | |
| # else | |
| # pragma comment(lib, GC_LIB "/Release/gc.lib") | |
| # endif | |
| #endif | |
| #ifdef XML | |
| # define GNOME_LIBS "/parser3project/win32xml/win32/gnome" | # define GNOME_LIBS "/parser3project/win32xml/win32/gnome" |
| # pragma comment(lib, GNOME_LIBS "/glib/lib/libglib-1.3-11.lib") | # pragma comment(lib, GNOME_LIBS "/glib/lib/libglib-1.3-11.lib") |
| # ifdef _DEBUG | # ifdef _DEBUG |
| # pragma comment(lib, GNOME_LIBS "/libxml2-x.x.x/win32/dsp/libxml2_so_debug/libxml2.lib") | |
| # pragma comment(lib, GNOME_LIBS "/libxslt-x.x.x/win32/dsp/libexslt_so_debug/libexslt.lib") | # ifdef LIBXML_STATIC |
| # pragma comment(lib, GNOME_LIBS "/libxslt-x.x.x/win32/dsp/libxslt_so_debug/libxslt.lib") | # pragma comment(lib, GNOME_LIBS "/gnome-xml/win32/dsp/libxml2_DebugStatic/libxml2.lib") |
| # pragma comment(lib, GNOME_LIBS "/gdome2-x.x.x/win32/dsp/Debug/libgdome.lib") | # else |
| # else | # pragma comment(lib, GNOME_LIBS "/gnome-xml/win32/dsp/libxml2_DebugDynamic/libxml2.lib") |
| # pragma comment(lib, GNOME_LIBS "/libxml2-x.x.x/win32/dsp/libxml2_so_release/libxml2.lib") | # endif |
| # pragma comment(lib, GNOME_LIBS "/libxslt-x.x.x/win32/dsp/libexslt_so_release/libexslt.lib") | |
| # pragma comment(lib, GNOME_LIBS "/libxslt-x.x.x/win32/dsp/libxslt_so_release/libxslt.lib") | # ifdef LIBXSLT_STATIC |
| # pragma comment(lib, GNOME_LIBS "/gdome2-x.x.x/win32/dsp/Release/libgdome.lib") | # pragma comment(lib, GNOME_LIBS "/libxslt-x.x.x/win32/dsp/libxslt_DebugStatic/libxslt.lib") |
| # else | |
| # pragma comment(lib, GNOME_LIBS "/libxslt-x.x.x/win32/dsp/libxslt_DebugDynamic/libxslt.lib") | |
| # endif | |
| # ifdef LIBEXSLT_STATIC | |
| # pragma comment(lib, GNOME_LIBS "/libxslt-x.x.x/win32/dsp/libexslt_DebugStatic/libexslt.lib") | |
| # else | |
| # pragma comment(lib, GNOME_LIBS "/libxslt-x.x.x/win32/dsp/libexslt_DebugDynamic/libexslt.lib") | |
| # endif | |
| # ifdef LIBGDOME_STATIC | |
| # pragma comment(lib, GNOME_LIBS "/gdome2-x.x.x/win32/dsp/libgdome_DebugStatic/libgdome.lib") | |
| # else | |
| # pragma comment(lib, GNOME_LIBS "/gdome2-x.x.x/win32/dsp/libgdome_DebugDynamic/libgdome.lib") | |
| # endif | |
| #else | |
| # ifdef LIBXML_STATIC | |
| # pragma comment(lib, GNOME_LIBS "/gnome-xml/win32/dsp/libxml2_ReleaseStatic/libxml2.lib") | |
| # else | |
| # pragma comment(lib, GNOME_LIBS "/gnome-xml/win32/dsp/libxml2_ReleaseDynamic/libxml2.lib") | |
| # endif | |
| # ifdef LIBXSLT_STATIC | |
| # pragma comment(lib, GNOME_LIBS "/libxslt-x.x.x/win32/dsp/libxslt_ReleaseStatic/libxslt.lib") | |
| # else | |
| # pragma comment(lib, GNOME_LIBS "/libxslt-x.x.x/win32/dsp/libxslt_ReleaseDynamic/libxslt.lib") | |
| # endif | |
| # ifdef LIBEXSLT_STATIC | |
| # pragma comment(lib, GNOME_LIBS "/libxslt-x.x.x/win32/dsp/libexslt_ReleaseStatic/libexslt.lib") | |
| # else | |
| # pragma comment(lib, GNOME_LIBS "/libxslt-x.x.x/win32/dsp/libexslt_ReleaseDynamic/libexslt.lib") | |
| # endif | |
| # ifdef LIBGDOME_STATIC | |
| # pragma comment(lib, GNOME_LIBS "/gdome2-x.x.x/win32/dsp/libgdome_ReleaseStatic/libgdome.lib") | |
| # else | |
| # pragma comment(lib, GNOME_LIBS "/gdome2-x.x.x/win32/dsp/libgdome_ReleaseDynamic/libgdome.lib") | |
| # endif | |
| # endif | # endif |
| #endif | #endif |
| #endif |