You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xalan.apache.org by mh...@apache.org on 2004/11/24 00:32:44 UTC

cvs commit: xml-xalan/c/samples/SimpleTransform SimpleTransform.cpp

mhoyt       2004/11/23 15:32:44

  Modified:    c/samples/SimpleTransform SimpleTransform.cpp
  Log:
  Include an example of the ICU memory management feature.
  
  Revision  Changes    Path
  1.26      +38 -0     xml-xalan/c/samples/SimpleTransform/SimpleTransform.cpp
  
  Index: SimpleTransform.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/samples/SimpleTransform/SimpleTransform.cpp,v
  retrieving revision 1.25
  retrieving revision 1.26
  diff -u -r1.25 -r1.26
  --- SimpleTransform.cpp	14 Nov 2004 23:24:27 -0000	1.25
  +++ SimpleTransform.cpp	23 Nov 2004 23:32:44 -0000	1.26
  @@ -36,6 +36,38 @@
   #include "XalanMemoryManagerImpl.hpp"
   
   
  +/**
  + *  Example of the ICU's customizable memory management which can
  + *  be used conjunction with Xalan's pluggable memory management feature.
  + */
  +#if defined(XALAN_USE_ICU)
  +
  +#include "unicode/uclean.h"
  +
  +static XalanMemoryManagerImpl  s_memoryManager;
  +
  +void*
  +icu_malloc(const void * /* context */, size_t size)
  +{
  +    return s_memoryManager.allocate(size);
  +}
  +
  +void*
  +icu_realloc(const void * /* context */, void * mem, size_t size)
  +{
  +    s_memoryManager.deallocate(mem);
  +    return s_memoryManager.allocate(size);
  +}
  +
  +void icu_free(const void * /* context */, void * mem)
  +{
  +    s_memoryManager.deallocate(mem);
  +}
  +
  +#endif
  +
  +
  +
   int
   main(
   			int		argc,
  @@ -64,11 +96,17 @@
   
               XalanMemoryManagerImpl memoryManager;
   
  +#ifdef XALAN_USE_ICU
  +			UErrorCode status;
  +			u_setMemoryFunctions(0, icu_malloc, icu_realloc, icu_free, &status);
  +#endif 
  +
   			// Call the static initializer for Xerces.
   			XMLPlatformUtils::Initialize( 
                                       XMLUni::fgXercescDefaultLocale,
                                       0,
                                       0,
  +
                                       &memoryManager );
   
   			// Initialize Xalan.
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-cvs-help@xml.apache.org