Diff for /parser3/src/main/pa_globals.C between versions 1.152.2.19.2.11 and 1.152.2.19.2.15

version 1.152.2.19.2.11, 2003/04/01 11:11:55 version 1.152.2.19.2.15, 2003/04/09 08:40:25
Line 237  static char *pa_GC_strdup(const char *s) Line 237  static char *pa_GC_strdup(const char *s)
         memcpy(result, s, size);          memcpy(result, s, size);
         return result;          return result;
 }  }
   #endif
   
 #ifdef PA_DEBUG_XML_GC_MEMORY  void pa_CORD_oom_fn(void) {
           SAPI::abort("out of memory (while expanding string)");
 static char *  
 pa_xmlStrndup(const char *cur, int len) {  
     char*ret;  
       
     if ((cur == NULL) || (len < 0)) return(NULL);  
     ret = (char *) xmlMalloc((len + 1) * sizeof(char));  
     if (ret == NULL) {  
         xmlGenericError(xmlGenericErrorContext,  
                 "malloc of %ld byte failed\n",  
                 (len + 1) * (long)sizeof(char));  
         return(NULL);  
     }  
     memcpy(ret, cur, len * sizeof(char));  
     ret[len] = 0;  
     return(ret);  
 }  
   
 static char *  
 pa_debug_xmlStrdup(const char *cur) {  
     const char *p = cur;  
   
     if (cur == NULL) return(NULL);  
     while (*p != 0) p++; /* non input consuming */  
     return(pa_xmlStrndup(cur, p - cur));  
 }  
   
 const size_t HEADTAIL_SIZE=4;  
   
 static size_t debug_size(size_t user_size) {  
         return user_size+HEADTAIL_SIZE*2;  
 }  
   
 static void* fill_return_user(void* adebug_ptr, size_t pure_debug_size) {  
         char* debug_ptr=(char*)adebug_ptr;  
         memcpy(debug_ptr, "\xBB\xEE\xFF\x00", HEADTAIL_SIZE);  
         memcpy(debug_ptr+pure_debug_size-HEADTAIL_SIZE, "\xBB\xEE\xFF\x00", HEADTAIL_SIZE);  
   
         // pAD  
         size_t raw_debug_size=GC_size(adebug_ptr);  
         for(size_t i=pure_debug_size; i<raw_debug_size; i++)  
                 debug_ptr[i]='\xAD';  
   
         return debug_ptr+HEADTAIL_SIZE;  
 }  
 static void* check_return_debug(void* auser_ptr) {  
         char* user_ptr=(char*)auser_ptr;  
         char* debug_ptr=user_ptr-HEADTAIL_SIZE;  
   
         size_t raw_debug_size=GC_size(debug_ptr);  
         if(raw_debug_size==0)  
                 _asm int 3;  
   
         size_t pure_debug_size=raw_debug_size;  
         while(debug_ptr[pure_debug_size-1]=='\xAD')  
                 pure_debug_size--;  
   
         if(memcmp(debug_ptr, "\xBB\xEE\xFF\x00", HEADTAIL_SIZE)!=0)  
                 _asm int 3;  
         if(memcmp(debug_ptr+pure_debug_size-HEADTAIL_SIZE, "\xBB\xEE\xFF\x00", HEADTAIL_SIZE)!=0)  
                 _asm int 3;  
   
         return debug_ptr;  
 }  
   
 static bool pa_debug_xml=true;  
 static void* pa_debug_GC_malloc(size_t size) {  
         if(pa_debug_xml) {  
                 size=debug_size(size);  
                 return fill_return_user(GC_malloc(size), size);  
         } else  
                 return GC_malloc(size);  
 }  
   
 static void *pa_debug_GC_realloc(void *user_ptr, size_t size) {  
         if(!GC_is_visible(user_ptr))  
                 _asm int 3;  
         //printf("realloc: 0x%p -> %u\n", ptr, size);  
         if(pa_debug_xml) {  
                 size=debug_size(size);  
                 return fill_return_user(  
                         GC_realloc(  
                                 check_return_debug(user_ptr),   
                                 size),  
                         size);  
         } else  
                 return GC_realloc(user_ptr, size);  
 }  
   
 static void pa_debug_GC_free(void*) {  
         // ignore free  
 }  }
   
   /**
           @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  #endif
   
           CORD_oom_fn=pa_CORD_oom_fn;
   }
   
 #endif  /**
           @test hint on one should call this for each thread xmlSubstituteEntitiesDefault(1);
 /// @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
   
 #ifndef PA_DEBUG_DISABLE_GC  
   
         // asking to use GC memory  
 #ifndef PA_DEBUG_XML_GC_MEMORY  
         xmlMemSetup(  
                 /*xmlFreeFunc */GC_free,  
                 /*xmlMallocFunc */GC_malloc,  
                 /*xmlReallocFunc */GC_realloc,  
                 /*xmlStrdupFunc */pa_GC_strdup);  
 #else  
         xmlMemSetup(  
                 /*xmlFreeFunc */pa_debug_GC_free,  
                 /*xmlMallocFunc */pa_debug_GC_malloc,  
                 /*xmlReallocFunc */pa_debug_GC_realloc,  
                 /*xmlStrdupFunc */pa_debug_xmlStrdup);  
 #endif  
   
 #endif  
   
         /* First get a DOMImplementation reference */          /* First get a DOMImplementation reference */
         domimpl = gdome_di_mkref ();          domimpl = gdome_di_mkref ();
         /*          /*
Line 464  void pa_globals_init() { Line 373  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

Removed from v.1.152.2.19.2.11  
changed lines
  Added in v.1.152.2.19.2.15


E-mail: