]>
git.saurik.com Git - apple/icu.git/blob - icuSources/common/uobject.cpp
2 ******************************************************************************
4 * Copyright (C) 2002-2012, International Business Machines
5 * Corporation and others. All Rights Reserved.
7 ******************************************************************************
10 * tab size: 8 (not used)
13 * created on: 2002jun26
14 * created by: Markus W. Scherer
17 #include "unicode/uobject.h"
22 #if U_OVERRIDE_CXX_ALLOCATION
25 * Default implementation of UMemory::new/delete
26 * using uprv_malloc() and uprv_free().
28 * For testing, this is used together with a list of imported symbols to verify
29 * that ICU is not using the global ::new and ::delete operators.
31 * These operators can be implemented like this or any other appropriate way
32 * when customizing ICU for certain environments.
33 * Whenever ICU is customized in binary incompatible ways please be sure
34 * to use library name suffixes to distinguish such libraries from
37 * Instead of just modifying these C++ new/delete operators, it is usually best
38 * to modify the uprv_malloc()/uprv_free()/uprv_realloc() functions in cmemory.c.
40 * Memory test on Windows/MSVC 6:
41 * The global operators new and delete look as follows:
42 * 04F 00000000 UNDEF notype () External | ??2@YAPAXI@Z (void * __cdecl operator new(unsigned int))
43 * 03F 00000000 UNDEF notype () External | ??3@YAXPAX@Z (void __cdecl operator delete(void *))
45 * These lines are from output generated by the MSVC 6 tool dumpbin with
46 * dumpbin /symbols *.obj
48 * ??2@YAPAXI@Z and ??3@YAXPAX@Z are the linker symbols in the .obj
49 * files and are imported from msvcrtd.dll (in a debug build).
51 * Make sure that with the UMemory operators new and delete defined these two symbols
52 * do not appear in the dumpbin /symbols output for the ICU libraries!
54 * If such a symbol appears in the output then look in the preceding lines in the output
55 * for which file and function calls the global new or delete operator,
56 * and replace with uprv_malloc/uprv_free.
59 void * U_EXPORT2
UMemory::operator new(size_t size
) U_NO_THROW
{
60 return uprv_malloc(size
);
63 void U_EXPORT2
UMemory::operator delete(void *p
) U_NO_THROW
{
69 void * U_EXPORT2
UMemory::operator new[](size_t size
) U_NO_THROW
{
70 return uprv_malloc(size
);
73 void U_EXPORT2
UMemory::operator delete[](void *p
) U_NO_THROW
{
79 #if U_HAVE_DEBUG_LOCATION_NEW
80 void * U_EXPORT2
UMemory::operator new(size_t size
, const char* /*file*/, int /*line*/) U_NO_THROW
{
81 return UMemory::operator new(size
);
84 void U_EXPORT2
UMemory::operator delete(void* p
, const char* /*file*/, int /*line*/) U_NO_THROW
{
85 UMemory::operator delete(p
);
87 #endif /* U_HAVE_DEBUG_LOCATION_NEW */
92 UObject::~UObject() {}
94 UClassID
UObject::getDynamicClassID() const { return NULL
; }
100 U_CAPI
void U_EXPORT2
101 uprv_deleteUObject(void *obj
) {
102 delete static_cast<UObject
*>(obj
);