System documentation of the GNU Image-Finding Tool

CDebuggingMemoryManager.h
1 // -*- mode: c++ -*-
2 #ifndef _CDEBUGMEMORYMANAGER
3 #define _CDEBUGMEMORYMANAGER
4 #include "libMRML/include/uses-declarations.h"
5 #include <iostream>
6 // -*- mode: c++ -*-
7 /*
8 
9  GIFT, a flexible content based image retrieval system.
10  Copyright (C) 1998, 1999, 2000, 2001, 2002, CUI University of Geneva
11 
12  Copyright (C) 2003, 2004 Bayreuth University
13  2005 Bamberg University
14  This program is free software; you can redistribute it and/or modify
15  it under the terms of the GNU General Public License as published by
16  the Free Software Foundation; either version 2 of the License, or
17  (at your option) any later version.
18 
19  This program is distributed in the hope that it will be useful,
20  but WITHOUT ANY WARRANTY; without even the implied warranty of
21  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22  GNU General Public License for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with this program; if not, write to the Free Software
26  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27 
28 */
29 #include "libMRML/include/CMutex.h"
30 typedef long CDebuggingMemoryManagerSize;
31 
32 // we will allocate a chunk of 10 megs
33 #define MEMSIZE 20000000
34 
41 struct lTChunk{
42 public:
45 
48 
51 
54 
59  CDebuggingMemoryManagerSize mSize;
60 
67  long mMagic;
68 };
69 
76 protected:
77 
80  void FreeChunk(lTChunk* inChunk);
81 
86 
89 
91  const long cMagic;
93  const long cUnMagic;
94 
96  long cVM;
99 public:
100 
104  CDebuggingMemoryManager(const CDebuggingMemoryManagerSize inSize);
105 
107  void* getMem(CDebuggingMemoryManagerSize inSize);
108 
110  bool freeMem(void*);
111 
113  bool isValid()const;
114 
116  friend ostream& operator <<(ostream& outStream,
117  const CDebuggingMemoryManager& inMem);
118 };
119 
121 ostream& operator<<(ostream& o, const CDebuggingMemoryManager& inMem);
122 
124 extern CDebuggingMemoryManager gMemManager;
125 
126 #endif
lTChunk * mPrev
Previous Item in List.
Definition: CDebuggingMemoryManager.h:44
Class for memory management: This class gives you the full control about 1MByte of Memory...
Definition: CDebuggingMemoryManager.h:75
CDebuggingMemoryManagerSize mSize
Size of this Chunk.
Definition: CDebuggingMemoryManager.h:59
lTChunk * mPreceding
Previous Item in MEMORY.
Definition: CDebuggingMemoryManager.h:50
lTChunk * mUsedList
List of used memory chunks.
Definition: CDebuggingMemoryManager.h:85
lTChunk * mFreeList
List of free memory chunks.
Definition: CDebuggingMemoryManager.h:83
A structure, which is useful to maintain a twice connected list: A list of Chunks and a list of free/...
Definition: CDebuggingMemoryManager.h:41
const long cUnMagic
The magic number to invalidate lTChunk nodes.
Definition: CDebuggingMemoryManager.h:93
const long cMagic
The magic number for valid lTChunk nodes.
Definition: CDebuggingMemoryManager.h:91
lTChunk * mNext
Following Item in List.
Definition: CDebuggingMemoryManager.h:47
long mMagic
We will add to this some stuff to check if the end of this has been overwritten.
Definition: CDebuggingMemoryManager.h:67
This class offers an abstraction from the locking method used.
Definition: CMutex.h:40
lTChunk * mFollowing
Following Item in MEMORY.
Definition: CDebuggingMemoryManager.h:53
CMutex mMutex
for multithreading
Definition: CDebuggingMemoryManager.h:98
lTChunk * mBuffer
THE memory used by this memory administrator.
Definition: CDebuggingMemoryManager.h:88

Need for discussion? Want to contribute? Contact
help-gift@gnu.org Generated using Doxygen