Rev 300 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
324 | serge | 1 | |
2 | |||
3 | #ifdef __cplusplus |
||
4 | |||
5 | #endif /* __cplusplus */ |
||
6 | |||
7 | typedef unsigned int dword; |
||
8 | |||
9 | |||
10 | |||
11 | |||
12 | |||
300 | serge | 13 | #define INUSE_BITS 3 |
14 | |||
15 | |||
16 | |||
324 | serge | 17 | |
18 | char* base; /* base address */ |
||
19 | dword size; /* allocated size */ |
||
20 | struct m_seg* next; /* ptr to next segment */ |
||
21 | dword flags; /* mmap and extern flag */ |
||
22 | }; |
||
23 | |||
24 | struct m_chunk |
||
25 | |||
26 | dword prev_foot; /* Size of previous chunk (if free). */ |
||
27 | dword head; /* Size and inuse bits. */ |
||
28 | struct m_chunk* fd; /* double links -- used only if free. */ |
||
29 | struct m_chunk* bk; |
||
30 | }; |
||
31 | |||
32 | typedef struct m_chunk* mchunkptr; |
||
33 | |||
34 | struct t_chunk |
||
35 | |||
36 | /* The first four fields must be compatible with malloc_chunk */ |
||
37 | dword prev_foot; |
||
38 | dword head; |
||
39 | |||
40 | struct t_chunk* fd; |
||
41 | |||
42 | |||
43 | struct t_chunk* child[2]; |
||
44 | |||
45 | struct t_chunk* parent; |
||
46 | |||
47 | }; |
||
48 | |||
49 | typedef struct t_chunk* tchunkptr; |
||
50 | |||
51 | |||
52 | typedef struct m_state |
||
53 | |||
54 | dword smallmap; |
||
55 | dword treemap; |
||
56 | // DWORD dvsize; |
||
57 | dword topsize; |
||
58 | char* least_addr; |
||
59 | // mchunkptr dv; |
||
60 | mchunkptr top; |
||
61 | dword magic; |
||
62 | struct m_chunk smallbins[32]; |
||
63 | tbinptr treebins[32]; |
||
64 | }; |
||
65 | |||
66 | |||
67 | |||
68 | |||
69 | void* _cdecl dlrealloc(void *,size_t); |
||
70 | void _cdecl dlfree(void*); |
||
71 | |||
72 | |||
73 | |||
74 | |||
75 | static void insert_chunk(mchunkptr P, size_t S); |
||
76 | |||
77 | |||
78 | static void unlink_large_chunk(tchunkptr X); |
||
79 | |||
80 | //void replace_dv(mchunkptr P, size_t S); |
||
81 | |||
82 | static void* malloc_large(size_t nb); |
||
83 | |||
84 | #define leftshift_for_tree_index(i) \ |
||
85 | |||
86 | |||
87 | #define leftmost_child(t) ((t)->child[0] != 0? (t)->child[0] : (t)->child[1]) |
||
88 | |||
89 | #define mem2chunk(mem) (mchunkptr)((char*)mem - 8) |
||
90 | #define chunk_plus_offset(p, s) ((mchunkptr)(((char*)(p)) + (s))) |
||
91 | |||
92 | |||
93 | |||
94 | |||
95 | #endif /* __cplusplus */ |
||
96 |