diff --git a/icu4c/source/common/unicode/uobject.h b/icu4c/source/common/unicode/uobject.h index 1f8fbef857a..886c923487e 100644 --- a/icu4c/source/common/unicode/uobject.h +++ b/icu4c/source/common/unicode/uobject.h @@ -28,6 +28,7 @@ U_NAMESPACE_BEGIN /* TODO undefine this symbol except for tests! See uobject.cpp */ // #define U_CPP_MEMORY_TEST +#define U_OVERRIDE_CXX_ALLOCATION 1 /** * UObject is the common ICU base class. @@ -59,18 +60,27 @@ public: */ virtual inline ~UObject() {} - // possible overrides for ICU4C C++ memory management, - // not provided by ICU itself; - // simple, non-class types are allocated using the macros in common/cmemory.h - // (uprv_malloc(), uprv_free(), uprv_realloc()); - // they or something else could be used here to implement C++ new/delete - // for ICU4C C++ classes -#define U_CPP_MEMORY_TEST -#ifdef U_CPP_MEMORY_TEST +#ifdef U_OVERRIDE_CXX_ALLOCATION + /** + * Overrides for ICU4C C++ memory management. + * simple, non-class types are allocated using the macros in common/cmemory.h + * (uprv_malloc(), uprv_free(), uprv_realloc()); + * they or something else could be used here to implement C++ new/delete + * for ICU4C C++ classes + * @draft ICU 2.2 + */ void *operator new(size_t size); + /** + * Overrides for ICU4C C++ memory management. + * simple, non-class types are allocated using the macros in common/cmemory.h + * (uprv_malloc(), uprv_free(), uprv_realloc()); + * they or something else could be used here to implement C++ new/delete + * for ICU4C C++ classes + * @draft ICU 2.2 + */ void operator delete(void *p); -#if 0 +#if U_CXX_MEMORY_TEST /* Sun Forte really dislikes these functions. */ void *operator new[](size_t size); void operator delete[](void *p); diff --git a/icu4c/source/common/uobject.cpp b/icu4c/source/common/uobject.cpp index d0db4418cf4..79b7749a612 100644 --- a/icu4c/source/common/uobject.cpp +++ b/icu4c/source/common/uobject.cpp @@ -14,17 +14,14 @@ * created by: Markus W. Scherer */ -#include "unicode/utypes.h" #include "unicode/uobject.h" -#ifdef U_CPP_MEMORY_TEST -# include "cmemory.h" -#endif +#ifdef U_OVERRIDE_CXX_ALLOCATION + +#include "cmemory.h" U_NAMESPACE_BEGIN -#ifdef U_CPP_MEMORY_TEST - /* * Test implementation of UObject::new/delete * using uprv_malloc() and uprv_free(). @@ -66,7 +63,7 @@ void UObject::operator delete(void *p) { } } -#if 0 +#if U_CXX_MEMORY_TEST void *UObject::operator new[](size_t size) { return uprv_malloc(size); } @@ -90,6 +87,7 @@ void UObject::operator delete[](void *p, size_t /* size */) { } #endif +U_NAMESPACE_END + #endif -U_NAMESPACE_END