2002-06-27 01:37:52 +00:00
|
|
|
/*
|
|
|
|
******************************************************************************
|
|
|
|
*
|
|
|
|
* Copyright (C) 2002, International Business Machines
|
|
|
|
* Corporation and others. All Rights Reserved.
|
|
|
|
*
|
|
|
|
******************************************************************************
|
|
|
|
* file name: uobject.h
|
|
|
|
* encoding: US-ASCII
|
|
|
|
* tab size: 8 (not used)
|
|
|
|
* indentation:4
|
|
|
|
*
|
|
|
|
* created on: 2002jun26
|
|
|
|
* created by: Markus W. Scherer
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "unicode/utypes.h"
|
|
|
|
#include "unicode/uobject.h"
|
|
|
|
|
2002-07-16 15:47:46 +00:00
|
|
|
#ifdef U_CPP_MEMORY_TEST
|
|
|
|
# include "cmemory.h"
|
|
|
|
#endif
|
|
|
|
|
2002-06-27 01:37:52 +00:00
|
|
|
U_NAMESPACE_BEGIN
|
|
|
|
|
2002-07-16 15:47:46 +00:00
|
|
|
#ifdef U_CPP_MEMORY_TEST
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Test implementation of UObject::new/delete
|
|
|
|
* using uprv_malloc() and uprv_free().
|
|
|
|
* This is used together with a list of imported symbols to verify
|
|
|
|
* that ICU is not using the global ::new and ::delete operators.
|
|
|
|
*
|
|
|
|
* These operators can be implemented like this or any other appropriate way
|
|
|
|
* when customizing ICU for certain environments.
|
|
|
|
* Whenever ICU is customized in binary incompatible ways please be sure
|
|
|
|
* to use library name suffixes to distinguish such libraries from
|
|
|
|
* the standard build.
|
|
|
|
*
|
|
|
|
* Memory test on Windows/MSVC 6:
|
|
|
|
* The global operators new and delete look as follows:
|
2002-07-16 15:56:35 +00:00
|
|
|
* 04F 00000000 UNDEF notype () External | ??2@YAPAXI@Z (void * __cdecl operator new(unsigned int))
|
2002-07-16 15:47:46 +00:00
|
|
|
* 03F 00000000 UNDEF notype () External | ??3@YAXPAX@Z (void __cdecl operator delete(void *))
|
|
|
|
*
|
|
|
|
* These lines are from output generated by the MSVC 6 tool dumpbin with
|
|
|
|
* dumpbin /symbols *.obj
|
|
|
|
*
|
2002-07-16 15:56:35 +00:00
|
|
|
* ??2@YAPAXI@Z and ??3@YAXPAX@Z are the linker symbols in the .obj
|
2002-07-16 15:47:46 +00:00
|
|
|
* files and are imported from msvcrtd.dll (in a debug build).
|
|
|
|
*
|
|
|
|
* Make sure that with the UObject operators new and delete defined these two symbols
|
|
|
|
* do not appear in the dumpbin /symbols output for the ICU libraries!
|
|
|
|
*
|
|
|
|
* If such a symbol appears in the output then look in the preceding lines in the output
|
|
|
|
* for which file and function calls the global new or delete operator,
|
|
|
|
* and replace with uprv_malloc/uprv_free.
|
|
|
|
*/
|
|
|
|
|
|
|
|
void *UObject::operator new(size_t size) {
|
|
|
|
return uprv_malloc(size);
|
|
|
|
}
|
|
|
|
|
|
|
|
void *UObject::operator new[](size_t size) {
|
|
|
|
return uprv_malloc(size);
|
|
|
|
}
|
|
|
|
|
|
|
|
void UObject::operator delete(void *p) {
|
|
|
|
if(p!=NULL) {
|
|
|
|
uprv_free(p);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void UObject::operator delete[](void *p) {
|
|
|
|
if(p!=NULL) {
|
|
|
|
uprv_free(p);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void UObject::operator delete(void *p, size_t /* size */) {
|
|
|
|
if(p!=NULL) {
|
|
|
|
uprv_free(p);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void UObject::operator delete[](void *p, size_t /* size */) {
|
|
|
|
if(p!=NULL) {
|
|
|
|
uprv_free(p);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2002-06-27 01:37:52 +00:00
|
|
|
U_NAMESPACE_END
|