forked from lxjhk/blockchain_parser
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMemoryMap.cpp
More file actions
45 lines (37 loc) · 698 Bytes
/
Copy pathMemoryMap.cpp
File metadata and controls
45 lines (37 loc) · 698 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include "MemoryMap.h"
#include <stdio.h>
#include <stdlib.h>
//#include <malloc.h>
class MemoryMapImpl :public MemoryMap
{
public:
MemoryMapImpl(const char *mappingObject,uint64_t size,bool createOk)
{
mData = NULL;
mData = malloc(size);
}
~MemoryMapImpl(void)
{
free(mData);
}
virtual void *getBaseAddress(void)
{
return mData;
}
virtual void release(void)
{
delete this;
}
uint64_t mMapSize;
void *mData;
};
MemoryMap * createMemoryMap(const char *fileName,uint64_t size,bool createOk)
{
MemoryMapImpl *m = new MemoryMapImpl(fileName,size,createOk);
if ( m->getBaseAddress() == NULL )
{
m->release();
m = NULL;
}
return static_cast< MemoryMap *>(m);
}