]>
git.saurik.com Git - apple/icu.git/blob - icuSources/tools/memcheck/ICUMemCheck.pl
1 # ***********************************************************************
3 # * Copyright (c) 2004-2006, International Business Machines Corporation
4 # * and others. All Rights Reserved.
5 # ***********************************************************************
7 # This perl script checks for correct memory function usage in ICU library code.
8 # It works with Linux builds of ICU using gcc.
13 # 3. perl ICUMemCheck.pl
15 # All object files containing direct references to C or C++ runtime library memory
16 # functions will be listed in the output.
18 # For ICU 3.6, the expected output is
19 # common/uniset.o U operator delete(void*)
20 # common/unifilt.o U operator delete(void*)
21 # common/cmemory.o U malloc
22 # common/cmemory.o U free
23 # i18n/strrepl.o U operator delete(void*)
24 # layout/LEFontInstance.o U operator delete(void*)
25 # layout/LEGlyphStorage.o U operator delete(void*)
26 # layout/LayoutEngine.o U operator delete(void*)
28 # cmemory.c Expected failures from uprv_malloc, uprv_free implementation.
29 # uniset.cpp Fails because of SymbolTable::~SymbolTable()
30 # unifilt.cpp Fails because of UnicodeMatcher::~UnicodeMatcher()
31 # strrepl.cpp Fails because of UnicodeReplacer::~UnicodeReplacer()
32 # LayoutEngine.cpp Fails because of LEGlyphFilter::~LEGlyphFilter()
33 # LEGlyphStorage.cpp Fails because of LEInsertionCallback::~LEInsertionCallback()
34 # LEFontInstance.cpp Fails because of LECharMapper::~LECharMapper
36 # To verify that no additional problems exist in the .cpp files, #ifdef out the
37 # offending destructors, rebuild icu, and re-run the tool. The problems should
40 # The problem destructors all are for mix-in style interface classes.
41 # These classes can not derive from UObject or UMemory because of multiple-inheritance
42 # problems, so they don't get the ICU memory functions. The delete code
43 # in the destructors will never be called because stand-alone instances of
44 # the classes cannot exist.
46 $fileNames = `find common i18n layout io -name "*.o" -print`;
47 foreach $f (split('\n', $fileNames)) {
48 $symbols = `nm -u -C $f`;
49 if ($symbols =~ /U +operator delete\(void\*\)/) {
52 if ($symbols =~ /U +operator delete\[\]\(void\*\)/) {
55 if ($symbols =~ /U +operator new\(unsigned int\)/) {
58 if ($symbols =~ /U +operator new\[\]\(unsigned int\)/) {
61 if ($symbols =~ /U +malloc.*/) {
64 if ($symbols =~ /U +free.*/) {