KaliVeda
Toolkit for HIC analysis
Loading...
Searching...
No Matches
KVMemoryChunk.cpp
1//Created by KVClassFactory on Fri Oct 1 16:50:15 2010
2//Author: John Frankland,,,,
3
4#include "KVMemoryChunk.h"
5#include <cstdlib>
6
8
9
10
12
14 : fMemory(0), fSize(0), fUsed(0), fNext(0)
15{
16 // Default constructor
17}
18
19
20
23
24KVMemoryChunk::KVMemoryChunk(size_t bytes) : fNext(0)
25{
26 // Allocate new chunk of size 'bytes'
27 fMemory = (char*) malloc(bytes);
28 fSize = bytes;
29 fUsed = 0;
30}
31
32
33
36
38{
39 // Destructor
40 if (fMemory) free(fMemory);
41 fMemory = 0;
42}
43
44
45
49
50void* KVMemoryChunk::GetMemory(size_t bytes)
51{
52 // Return pointer to block of memory of size 'bytes'
53 // If no block of this size is available, returns 0 (test it!!)
54
55 if (fUsed + bytes <= fSize) {
56 void* p = (void*)(fMemory + fUsed);
57 fUsed += bytes;
58 return p;
59 }
60 return NULL;
61}
62
63
65
67{
68 printf("KVMemoryChunk: %lu bytes (%lu used) at: %p\n",
70};
71
72
73
winID h TVirtualViewer3D TVirtualGLPainter p
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t bytes
#define free
#define malloc
Memory handled by KVMemoryPool.
virtual ~KVMemoryChunk()
Destructor.
size_t fSize
size of chunk in bytes
char * fMemory
pointer to start of chunk
void * GetMemory(size_t)
size_t fUsed
memory used in bytes
KVMemoryChunk()
Default constructor.
ClassImp(TPyArg)