ICU-11122 Remove global operator new & delete. They were non-standards conforming, and not easily fixed. Were for error check & debug purposes only.

X-SVN-Rev: 39150
This commit is contained in:
Andy Heninger 2016-09-07 17:22:42 +00:00
parent ec3948198e
commit ecdc261090

View File

@ -375,88 +375,6 @@ typedef double UDate;
#define U_STANDARD_CPP_NAMESPACE
#endif
/*===========================================================================*/
/* Global delete operator */
/*===========================================================================*/
/*
* The ICU4C library must not use the global new and delete operators.
* These operators here are defined to enable testing for this.
* See Jitterbug 2581 for details of why this is necessary.
*
* Verification that ICU4C's memory usage is correct, i.e.,
* that global new/delete are not used:
*
* a) Check for imports of global new/delete (see uobject.cpp for details)
* b) Verify that new is never imported.
* c) Verify that delete is only imported from object code for interface/mixin classes.
* d) Add global delete and delete[] only for the ICU4C library itself
* and define them in a way that crashes or otherwise easily shows a problem.
*
* The following implements d).
* The operator implementations crash; this is intentional and used for library debugging.
*
* Note: This is currently only done on Windows because
* some Linux/Unix compilers have problems with defining global new/delete.
* On Windows, it is _MSC_VER>=1200 for MSVC 6.0 and higher.
*/
#if defined(__cplusplus) && U_DEBUG && U_OVERRIDE_CXX_ALLOCATION && (_MSC_VER>=1200) && !defined(U_STATIC_IMPLEMENTATION) && (defined(U_COMMON_IMPLEMENTATION) || defined(U_I18N_IMPLEMENTATION) || defined(U_IO_IMPLEMENTATION) || defined(U_LAYOUT_IMPLEMENTATION) || defined(U_LAYOUTEX_IMPLEMENTATION))
#ifndef U_HIDE_INTERNAL_API
/**
* Global operator new, defined only inside ICU4C, must not be used.
* Crashes intentionally.
* @internal
*/
inline void *
operator new(size_t /*size*/) {
char *q=NULL;
*q=5; /* break it */
return q;
}
#ifdef _Ret_bytecap_
/* This is only needed to suppress a Visual C++ 2008 warning for operator new[]. */
_Ret_bytecap_(_Size)
#endif
/**
* Global operator new[], defined only inside ICU4C, must not be used.
* Crashes intentionally.
* @internal
*/
inline void *
operator new[](size_t /*size*/) {
char *q=NULL;
*q=5; /* break it */
return q;
}
/**
* Global operator delete, defined only inside ICU4C, must not be used.
* Crashes intentionally.
* @internal
*/
inline void
operator delete(void * /*p*/) {
char *q=NULL;
*q=5; /* break it */
}
/**
* Global operator delete[], defined only inside ICU4C, must not be used.
* Crashes intentionally.
* @internal
*/
inline void
operator delete[](void * /*p*/) {
char *q=NULL;
*q=5; /* break it */
}
#endif /* U_HIDE_INTERNAL_API */
#endif
/*===========================================================================*/
/* UErrorCode */
/*===========================================================================*/