-
Notifications
You must be signed in to change notification settings - Fork 0
/
memory_pool.h
59 lines (45 loc) · 1.22 KB
/
memory_pool.h
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#ifndef PDLN_MEMORY_POOL_H
#define PDLN_MEMORY_POOL_H
#include <cstddef>
#include <vector>
#include "triangle.h"
/* freed chunk */
struct Bin {
Bin* next;
};
class Triangle_pool {
public:
Triangle_pool();
~Triangle_pool();
Triangle* alloc();
void free(Triangle*);
Triangle* newElement();
void deleteElement(Triangle*);
void get_all_leaf_triangle(std::vector<Triangle*>&);
private:
Triangle* get_page_body(char*);
Triangle* get_page_end(char*);
void allocNewPage();
size_t pagesize;
char* cur_page; // current operating page
Triangle* top_chunk; // first unallocated chunk
Triangle* end_chunk;
Bin* bins; // freed chunk list
};
class Edge_pool {
public:
Edge_pool();
~Edge_pool();
Edge* alloc();
void free(Edge*);
Edge* newElement();
void deleteElement(Edge*);
private:
void allocNewPage();
size_t pagesize;
char* cur_page; // current operating page
Edge* top_chunk; // first unallocated chunk
Edge* end_chunk;
Bin* bins; // freed chunk list
};
#endif