]>
git.saurik.com Git - apple/icu.git/blob - icuSources/common/uobject.cpp
1 // © 2016 and later: Unicode, Inc. and others.
2 // License & terms of use: http://www.unicode.org/copyright.html
4 ******************************************************************************
6 * Copyright (C) 2002-2012, International Business Machines
7 * Corporation and others. All Rights Reserved.
9 ******************************************************************************
10 * file name: uobject.h
12 * tab size: 8 (not used)
15 * created on: 2002jun26
16 * created by: Markus W. Scherer
19 #include "unicode/uobject.h"
24 #if U_OVERRIDE_CXX_ALLOCATION
27 * Default implementation of UMemory::new/delete
28 * using uprv_malloc() and uprv_free().
30 * For testing, this is used together with a list of imported symbols to verify
31 * that ICU is not using the global ::new and ::delete operators.
33 * These operators can be implemented like this or any other appropriate way
34 * when customizing ICU for certain environments.
35 * Whenever ICU is customized in binary incompatible ways please be sure
36 * to use library name suffixes to distinguish such libraries from
39 * Instead of just modifying these C++ new/delete operators, it is usually best
40 * to modify the uprv_malloc()/uprv_free()/uprv_realloc() functions in cmemory.c.
42 * Memory test on Windows/MSVC 6:
43 * The global operators new and delete look as follows:
44 * 04F 00000000 UNDEF notype () External | ??2@YAPAXI@Z (void * __cdecl operator new(unsigned int))
45 * 03F 00000000 UNDEF notype () External | ??3@YAXPAX@Z (void __cdecl operator delete(void *))
47 * These lines are from output generated by the MSVC 6 tool dumpbin with
48 * dumpbin /symbols *.obj
50 * ??2@YAPAXI@Z and ??3@YAXPAX@Z are the linker symbols in the .obj
51 * files and are imported from msvcrtd.dll (in a debug build).
53 * Make sure that with the UMemory operators new and delete defined these two symbols
54 * do not appear in the dumpbin /symbols output for the ICU libraries!
56 * If such a symbol appears in the output then look in the preceding lines in the output
57 * for which file and function calls the global new or delete operator,
58 * and replace with uprv_malloc/uprv_free.
61 void * U_EXPORT2
UMemory::operator new(size_t size
) U_NO_THROW
{
62 return uprv_malloc(size
);
65 void U_EXPORT2
UMemory::operator delete(void *p
) U_NO_THROW
{
71 void * U_EXPORT2
UMemory::operator new[](size_t size
) U_NO_THROW
{
72 return uprv_malloc(size
);
75 void U_EXPORT2
UMemory::operator delete[](void *p
) U_NO_THROW
{
81 #if U_HAVE_DEBUG_LOCATION_NEW
82 void * U_EXPORT2
UMemory::operator new(size_t size
, const char* /*file*/, int /*line*/) U_NO_THROW
{
83 return UMemory::operator new(size
);
86 void U_EXPORT2
UMemory::operator delete(void* p
, const char* /*file*/, int /*line*/) U_NO_THROW
{
87 UMemory::operator delete(p
);
89 #endif /* U_HAVE_DEBUG_LOCATION_NEW */
94 UObject::~UObject() {}
96 UClassID
UObject::getDynamicClassID() const { return NULL
; }
102 U_CAPI
void U_EXPORT2
103 uprv_deleteUObject(void *obj
) {
104 delete static_cast<UObject
*>(obj
);