Wed, 31 Dec 2014 07:22:50 +0100
Correct previous dual key logic pending first delivery installment.
michael@0 | 1 | /* |
michael@0 | 2 | ****************************************************************************** |
michael@0 | 3 | * |
michael@0 | 4 | * Copyright (C) 2002-2012, International Business Machines |
michael@0 | 5 | * Corporation and others. All Rights Reserved. |
michael@0 | 6 | * |
michael@0 | 7 | ****************************************************************************** |
michael@0 | 8 | * file name: uobject.h |
michael@0 | 9 | * encoding: US-ASCII |
michael@0 | 10 | * tab size: 8 (not used) |
michael@0 | 11 | * indentation:4 |
michael@0 | 12 | * |
michael@0 | 13 | * created on: 2002jun26 |
michael@0 | 14 | * created by: Markus W. Scherer |
michael@0 | 15 | */ |
michael@0 | 16 | |
michael@0 | 17 | #include "unicode/uobject.h" |
michael@0 | 18 | #include "cmemory.h" |
michael@0 | 19 | |
michael@0 | 20 | U_NAMESPACE_BEGIN |
michael@0 | 21 | |
michael@0 | 22 | #if U_OVERRIDE_CXX_ALLOCATION |
michael@0 | 23 | |
michael@0 | 24 | /* |
michael@0 | 25 | * Default implementation of UMemory::new/delete |
michael@0 | 26 | * using uprv_malloc() and uprv_free(). |
michael@0 | 27 | * |
michael@0 | 28 | * For testing, this is used together with a list of imported symbols to verify |
michael@0 | 29 | * that ICU is not using the global ::new and ::delete operators. |
michael@0 | 30 | * |
michael@0 | 31 | * These operators can be implemented like this or any other appropriate way |
michael@0 | 32 | * when customizing ICU for certain environments. |
michael@0 | 33 | * Whenever ICU is customized in binary incompatible ways please be sure |
michael@0 | 34 | * to use library name suffixes to distinguish such libraries from |
michael@0 | 35 | * the standard build. |
michael@0 | 36 | * |
michael@0 | 37 | * Instead of just modifying these C++ new/delete operators, it is usually best |
michael@0 | 38 | * to modify the uprv_malloc()/uprv_free()/uprv_realloc() functions in cmemory.c. |
michael@0 | 39 | * |
michael@0 | 40 | * Memory test on Windows/MSVC 6: |
michael@0 | 41 | * The global operators new and delete look as follows: |
michael@0 | 42 | * 04F 00000000 UNDEF notype () External | ??2@YAPAXI@Z (void * __cdecl operator new(unsigned int)) |
michael@0 | 43 | * 03F 00000000 UNDEF notype () External | ??3@YAXPAX@Z (void __cdecl operator delete(void *)) |
michael@0 | 44 | * |
michael@0 | 45 | * These lines are from output generated by the MSVC 6 tool dumpbin with |
michael@0 | 46 | * dumpbin /symbols *.obj |
michael@0 | 47 | * |
michael@0 | 48 | * ??2@YAPAXI@Z and ??3@YAXPAX@Z are the linker symbols in the .obj |
michael@0 | 49 | * files and are imported from msvcrtd.dll (in a debug build). |
michael@0 | 50 | * |
michael@0 | 51 | * Make sure that with the UMemory operators new and delete defined these two symbols |
michael@0 | 52 | * do not appear in the dumpbin /symbols output for the ICU libraries! |
michael@0 | 53 | * |
michael@0 | 54 | * If such a symbol appears in the output then look in the preceding lines in the output |
michael@0 | 55 | * for which file and function calls the global new or delete operator, |
michael@0 | 56 | * and replace with uprv_malloc/uprv_free. |
michael@0 | 57 | */ |
michael@0 | 58 | |
michael@0 | 59 | void * U_EXPORT2 UMemory::operator new(size_t size) U_NO_THROW { |
michael@0 | 60 | return uprv_malloc(size); |
michael@0 | 61 | } |
michael@0 | 62 | |
michael@0 | 63 | void U_EXPORT2 UMemory::operator delete(void *p) U_NO_THROW { |
michael@0 | 64 | if(p!=NULL) { |
michael@0 | 65 | uprv_free(p); |
michael@0 | 66 | } |
michael@0 | 67 | } |
michael@0 | 68 | |
michael@0 | 69 | void * U_EXPORT2 UMemory::operator new[](size_t size) U_NO_THROW { |
michael@0 | 70 | return uprv_malloc(size); |
michael@0 | 71 | } |
michael@0 | 72 | |
michael@0 | 73 | void U_EXPORT2 UMemory::operator delete[](void *p) U_NO_THROW { |
michael@0 | 74 | if(p!=NULL) { |
michael@0 | 75 | uprv_free(p); |
michael@0 | 76 | } |
michael@0 | 77 | } |
michael@0 | 78 | |
michael@0 | 79 | #if U_HAVE_DEBUG_LOCATION_NEW |
michael@0 | 80 | void * U_EXPORT2 UMemory::operator new(size_t size, const char* /*file*/, int /*line*/) U_NO_THROW { |
michael@0 | 81 | return UMemory::operator new(size); |
michael@0 | 82 | } |
michael@0 | 83 | |
michael@0 | 84 | void U_EXPORT2 UMemory::operator delete(void* p, const char* /*file*/, int /*line*/) U_NO_THROW { |
michael@0 | 85 | UMemory::operator delete(p); |
michael@0 | 86 | } |
michael@0 | 87 | #endif /* U_HAVE_DEBUG_LOCATION_NEW */ |
michael@0 | 88 | |
michael@0 | 89 | |
michael@0 | 90 | #endif |
michael@0 | 91 | |
michael@0 | 92 | UObject::~UObject() {} |
michael@0 | 93 | |
michael@0 | 94 | UClassID UObject::getDynamicClassID() const { return NULL; } |
michael@0 | 95 | |
michael@0 | 96 | U_NAMESPACE_END |
michael@0 | 97 | |
michael@0 | 98 | U_NAMESPACE_USE |
michael@0 | 99 | |
michael@0 | 100 | U_CAPI void U_EXPORT2 |
michael@0 | 101 | uprv_deleteUObject(void *obj) { |
michael@0 | 102 | delete static_cast<UObject *>(obj); |
michael@0 | 103 | } |