LCOV - code coverage report
Current view: top level - intl/icu/source/common - uobject.cpp (source / functions) Hit Total Coverage
Test: output.info Lines: 3 17 17.6 %
Date: 2017-07-14 16:53:18 Functions: 2 8 25.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : // © 2016 and later: Unicode, Inc. and others.
       2             : // License & terms of use: http://www.unicode.org/copyright.html
       3             : /*
       4             : ******************************************************************************
       5             : *
       6             : *   Copyright (C) 2002-2012, International Business Machines
       7             : *   Corporation and others.  All Rights Reserved.
       8             : *
       9             : ******************************************************************************
      10             : *   file name:  uobject.h
      11             : *   encoding:   UTF-8
      12             : *   tab size:   8 (not used)
      13             : *   indentation:4
      14             : *
      15             : *   created on: 2002jun26
      16             : *   created by: Markus W. Scherer
      17             : */
      18             : 
      19             : #include "unicode/uobject.h"
      20             : #include "cmemory.h"
      21             : 
      22             : U_NAMESPACE_BEGIN
      23             : 
      24             : #if U_OVERRIDE_CXX_ALLOCATION
      25             : 
      26             : /*
      27             :  * Default implementation of UMemory::new/delete
      28             :  * using uprv_malloc() and uprv_free().
      29             :  *
      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.
      32             :  *
      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
      37             :  * the standard build.
      38             :  *
      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.
      41             :  *
      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 *))
      46             :  *
      47             :  * These lines are from output generated by the MSVC 6 tool dumpbin with
      48             :  * dumpbin /symbols *.obj
      49             :  *
      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).
      52             :  *
      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!
      55             :  *
      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.
      59             :  */
      60             : 
      61          15 : void * U_EXPORT2 UMemory::operator new(size_t size) U_NO_THROW {
      62          15 :     return uprv_malloc(size);
      63             : }
      64             : 
      65           0 : void U_EXPORT2 UMemory::operator delete(void *p) U_NO_THROW {
      66           0 :     if(p!=NULL) {
      67           0 :         uprv_free(p);
      68             :     }
      69           0 : }
      70             : 
      71           0 : void * U_EXPORT2 UMemory::operator new[](size_t size) U_NO_THROW {
      72           0 :     return uprv_malloc(size);
      73             : }
      74             : 
      75           0 : void U_EXPORT2 UMemory::operator delete[](void *p) U_NO_THROW {
      76           0 :     if(p!=NULL) {
      77           0 :         uprv_free(p);
      78             :     }
      79           0 : }
      80             : 
      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);
      84             : }
      85             : 
      86             : void U_EXPORT2 UMemory::operator delete(void* p, const char* /*file*/, int /*line*/) U_NO_THROW {
      87             :     UMemory::operator delete(p);
      88             : }
      89             : #endif /* U_HAVE_DEBUG_LOCATION_NEW */
      90             : 
      91             : 
      92             : #endif
      93             : 
      94           1 : UObject::~UObject() {}
      95             : 
      96           0 : UClassID UObject::getDynamicClassID() const { return NULL; }
      97             : 
      98             : U_NAMESPACE_END
      99             : 
     100             : U_NAMESPACE_USE
     101             : 
     102             : U_CAPI void U_EXPORT2
     103           0 : uprv_deleteUObject(void *obj) {
     104           0 :     delete static_cast<UObject *>(obj);
     105           0 : }

Generated by: LCOV version 1.13