|
|
| version 1.152.2.19.2.12, 2003/04/01 12:05:46 | version 1.152.2.19.2.19, 2003/05/11 12:37:07 |
|---|---|
| Line 10 static const char* IDENT_GLOBALS_C="$Dat | Line 10 static const char* IDENT_GLOBALS_C="$Dat |
| #include "pa_config_includes.h" | #include "pa_config_includes.h" |
| #ifdef XML | #ifdef XML |
| #include "libxml/xmlversion.h" | |
| #include "libxslt/extensions.h" | #include "libxslt/extensions.h" |
| #include "libxslt/xsltutils.h" | #include "libxslt/xsltutils.h" |
| extern "C" { | extern "C" { |
| Line 17 extern "C" { | Line 18 extern "C" { |
| }; | }; |
| #endif | #endif |
| #include "pcre.h" | |
| #include "pa_globals.h" | #include "pa_globals.h" |
| #include "pa_string.h" | #include "pa_string.h" |
| #include "pa_sapi.h" | #include "pa_sapi.h" |
| Line 25 extern "C" { | Line 28 extern "C" { |
| // defines | // defines |
| #define PA_DEBUG_XML_GC_MEMORY | //#define PA_DEBUG_XML_GC_MEMORY |
| // globals | // globals |
| Line 228 void pa_globals_destroy(void *) { | Line 231 void pa_globals_destroy(void *) { |
| #ifdef XML | #ifdef XML |
| static char *pa_GC_strdup(const char *s) { | static char *pa_GC_strdup(const char *s) { |
| if(!s) | if(!s) |
| return 0; | return 0; |
| Line 237 static char *pa_GC_strdup(const char *s) | Line 241 static char *pa_GC_strdup(const char *s) |
| memcpy(result, s, size); | memcpy(result, s, size); |
| return result; | return result; |
| } | } |
| #endif | |
| /// @test hint on one should call this for each thread xmlSubstituteEntitiesDefault(1); | #ifdef PA_DEBUG_XML_GC_MEMORY |
| void pa_globals_init() { | void *pa_look_for[]={(void*)0x8abe000,(void*)0x0,(void*)0x0,(void*)0x0, |
| (void*)0x0,(void*)0x0,(void*)0x0,(void*)0x0}; | |
| bool pa_looked(void*p) { | |
| for(int i=0; i<8; i++) | |
| if(pa_look_for[i]==p) | |
| return true; | |
| return false; | |
| } | |
| static void* pa_gc_malloc_log(size_t size){ | |
| void *p=pa_gc_malloc(size); | |
| fprintf(stderr, "pa_gc_malloc_log(%d)=0x%p\n", size, p); | |
| // if(pa_looked(p)) | |
| // fprintf(stderr,"catched debug malloc(%d)=0x%p\n", size, p); | |
| return p; | |
| } | |
| static void* pa_gc_malloc_atomic_log(size_t size){ | |
| void *p=pa_gc_malloc_atomic(size); | |
| fprintf(stderr, "pa_gc_malloc_atomic_log(%d)=0x%p\n", size, p); | |
| // if(pa_looked(p)) | |
| // fprintf(stderr,"catched debug malloc atomic(%d)=0x%p\n", size, p); | |
| return p; | |
| } | |
| static void* pa_gc_realloc_log(void *ptr, size_t size){ | |
| void *p=pa_gc_realloc(ptr, size); | |
| fprintf(stderr, "pa_gc_realloc_log(0x%p, %d)=0x%p\n", ptr, size, p); | |
| // if(pa_looked(p)) | |
| // fprintf(stderr,"catched debug realloc(%d)=0x%p\n", size, p); | |
| return p; | |
| } | |
| //static void pa_gc_free_ignore(void *){} | |
| static void pa_gc_free_log(void *p){ | |
| fprintf(stderr, "pa_gc_free_log(0x%p)\n", p); | |
| // if(pa_looked(p)) | |
| // fprintf(stderr,"catched debug free(0x%p)\n", p); | |
| pa_gc_free(p); | |
| } | |
| #endif | |
| #endif | |
| // hex value | void pa_CORD_oom_fn(void) { |
| setup_hex_value(); | SAPI::abort("out of memory (while expanding string)"); |
| } | |
| /** | |
| @todo LIBXML_VERSION with xmlGcMemSetup will be 2.5.7 | |
| @todo gc: libltdl: substitute lt_dlmalloc & co | |
| */ | |
| static void gc_substitute_memory_management_functions() { | |
| // in libxml & libxslt | |
| #ifdef XML | #ifdef XML |
| // initializing xml libs | |
| #ifndef PA_DEBUG_DISABLE_GC | |
| // asking to use GC memory | // asking to use GC memory |
| #if LIBXML_VERSION >= 20507 | |
| #ifdef PA_DEBUG_XML_GC_MEMORY | |
| xmlGcMemSetup( | |
| /*xmlFreeFunc */pa_gc_free_log, | |
| /*xmlMallocFunc */pa_gc_malloc_log, | |
| /*xmlMallocFunc */pa_gc_malloc_atomic_log, | |
| /*xmlReallocFunc */pa_gc_realloc_log, | |
| /*xmlStrdupFunc */pa_GC_strdup); | |
| #else | |
| xmlGcMemSetup( | |
| /*xmlFreeFunc */pa_gc_free, | |
| /*xmlMallocFunc */pa_gc_malloc, | |
| /*xmlMallocFunc */pa_gc_malloc_atomic, | |
| /*xmlReallocFunc */pa_gc_realloc, | |
| /*xmlStrdupFunc */pa_GC_strdup); | |
| #endif | |
| #else | |
| xmlMemSetup( | xmlMemSetup( |
| /*xmlFreeFunc */pa_gc_free, | /*xmlFreeFunc */pa_gc_free, |
| /*xmlMallocFunc */pa_gc_malloc, | /*xmlMallocFunc */pa_gc_malloc, |
| Line 258 void pa_globals_init() { | Line 320 void pa_globals_init() { |
| /*xmlStrdupFunc */pa_GC_strdup); | /*xmlStrdupFunc */pa_GC_strdup); |
| #endif | #endif |
| #endif | |
| // pcre | |
| pcre_malloc=pa_gc_malloc; | |
| pcre_free=pa_gc_free; | |
| // cord | |
| CORD_oom_fn=pa_CORD_oom_fn; | |
| } | |
| /** | |
| @test hint on one should call this for each thread xmlSubstituteEntitiesDefault(1); | |
| */ | |
| void pa_globals_init() { | |
| // in various libraries | |
| gc_substitute_memory_management_functions(); | |
| // hex value | |
| setup_hex_value(); | |
| #ifdef XML | |
| // initializing xml libs | |
| /* First get a DOMImplementation reference */ | /* First get a DOMImplementation reference */ |
| domimpl = gdome_di_mkref (); | domimpl = gdome_di_mkref (); |
| /* | /* |
| Line 329 void pa_globals_init() { | Line 415 void pa_globals_init() { |
| # ifdef _DEBUG | # ifdef _DEBUG |
| # ifdef LIBXML_STATIC | # ifdef LIBXML_STATIC |
| # pragma comment(lib, GNOME_LIBS "/gnome-xml/win32/dsp/libxml2_DebugStatic/libxml2.lib") | # pragma comment(lib, GNOME_LIBS "/gnome-xml/win32/binaries/libxml2_a.lib") |
| # else | # else |
| # pragma comment(lib, GNOME_LIBS "/gnome-xml/win32/dsp/libxml2_DebugDynamic/libxml2.lib") | # pragma comment(lib, GNOME_LIBS "/gnome-xml/win32/binaries/libxml2.lib") |
| # endif | # endif |
| # ifdef LIBXSLT_STATIC | # ifdef LIBXSLT_STATIC |
| Line 356 void pa_globals_init() { | Line 442 void pa_globals_init() { |
| # ifdef LIBXML_STATIC | # ifdef LIBXML_STATIC |
| # pragma comment(lib, GNOME_LIBS "/gnome-xml/win32/dsp/libxml2_ReleaseStatic/libxml2.lib") | # pragma comment(lib, GNOME_LIBS "/gnome-xml/win32/dsp/libxml2_ReleaseStatic/libxml2.lib") |
| # else | # else |
| # pragma comment(lib, GNOME_LIBS "/gnome-xml/win32/dsp/lixml2_ReleaseDynamic/libxml2.lib") | # pragma comment(lib, GNOME_LIBS "/gnome-xml/win32/dsp/libxml2_ReleaseDynamic/libxml2.lib") |
| # endif | # endif |
| # ifdef LIBXSLT_STATIC | # ifdef LIBXSLT_STATIC |