XIOS  1.0
Xml I/O Server
 Tout Classes Espaces de nommage Fichiers Fonctions Variables Définitions de type Énumérations Valeurs énumérées Amis Macros
memtrack.hpp
Aller à la documentation de ce fichier.
1 #ifdef XIOS_MEMTRACK
2 /*
3 Copyright (c) 2002, 2008 Curtis Bartley
4 All rights reserved.
5 Redistribution and use in source and binary forms, with or without
6 modification, are permitted provided that the following conditions
7 are met:
8 
9 - Redistributions of source code must retain the above copyright
10 notice, this list of conditions and the following disclaimer.
11 
12 - Redistributions in binary form must reproduce the above copyright
13 notice, this list of conditions and the following disclaimer in the
14 documentation and/or other materials provided with the
15 distribution.
16 
17 - Neither the name of Curtis Bartley nor the names of any other
18 contributors may be used to endorse or promote products derived
19 from this software without specific prior written permission.
20 
21 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24 FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25 COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
27 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
28 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
30 STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
32 OF THE POSSIBILITY OF SUCH DAMAGE.
33 */
34 
35 #ifndef MemTrack_H_
36 #define MemTrack_H_
37 
38 #include <typeinfo>
39 #include <cstring>
40 
41 namespace MemTrack
42 {
43  /* ---------------------------------------- class MemStamp */
44 
45  class MemStamp
46  {
47  public: // member variables
48  char const * const filename;
49  int const lineNum;
50  public: // construction/destruction
51  MemStamp(char const *filename, int lineNum)
52  : filename(filename), lineNum(lineNum) { }
53  ~MemStamp() { }
54  };
55 
56  /* ---------------------------------------- memory allocation and stamping prototypes */
57 
58  void *TrackMalloc(size_t size);
59  void TrackFree(void *p);
60  void TrackStamp(void *p, const MemStamp &stamp, char const *typeName);
61  void TrackDumpBlocks();
62  void TrackListMemoryUsage();
63  size_t getCurrentMemorySize(void) ;
64  size_t getMaxMemorySize(void) ;
65  /* ---------------------------------------- operator * (MemStamp, ptr) */
66 
67  template <class T> inline T *operator*(const MemStamp &stamp, T *p)
68  {
69  TrackStamp(p, stamp, typeid(T).name());
70  return p;
71  }
72 
73 } // namespace MemTrack
74 
75 /* ---------------------------------------- new macro */
76 
77 #define MEMTRACK_NEW MemTrack::MemStamp(__FILE__, __LINE__) * new
78 #define new MEMTRACK_NEW
79 
80 #endif // MemTrack_H_
81 
82 #endif
CDuration operator*(const double &scal, const CDuration &ddr)
////////////////////// Définitions ////////////////////// ///