Mercurial > projects > ldc
comparison dmd/mem.h @ 1:c53b6e3fe49a trunk
[svn r5] Initial commit. Most things are very rough.
author | lindquist |
---|---|
date | Sat, 01 Sep 2007 21:43:27 +0200 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
0:a9e71648e74d | 1:c53b6e3fe49a |
---|---|
1 // Copyright (C) 2000-2001 by Chromium Communications | |
2 // All Rights Reserved | |
3 | |
4 #ifndef ROOT_MEM_H | |
5 #define ROOT_MEM_H | |
6 | |
7 #include <stddef.h> // for size_t | |
8 | |
9 typedef void (*FINALIZERPROC)(void* pObj, void* pClientData); | |
10 | |
11 struct GC; // thread specific allocator | |
12 | |
13 struct Mem | |
14 { | |
15 GC *gc; // pointer to our thread specific allocator | |
16 Mem() { gc = NULL; } | |
17 | |
18 void init(); | |
19 | |
20 // Derive from Mem to get these storage allocators instead of global new/delete | |
21 void * operator new(size_t m_size); | |
22 void * operator new(size_t m_size, Mem *mem); | |
23 void * operator new(size_t m_size, GC *gc); | |
24 void operator delete(void *p); | |
25 | |
26 void * operator new[](size_t m_size); | |
27 void operator delete[](void *p); | |
28 | |
29 char *strdup(const char *s); | |
30 void *malloc(size_t size); | |
31 void *malloc_uncollectable(size_t size); | |
32 void *calloc(size_t size, size_t n); | |
33 void *realloc(void *p, size_t size); | |
34 void free(void *p); | |
35 void free_uncollectable(void *p); | |
36 void *mallocdup(void *o, size_t size); | |
37 void error(); | |
38 void check(void *p); // validate pointer | |
39 void fullcollect(); // do full garbage collection | |
40 void fullcollectNoStack(); // do full garbage collection, no scan stack | |
41 void mark(void *pointer); | |
42 void addroots(char* pStart, char* pEnd); | |
43 void removeroots(char* pStart); | |
44 void setFinalizer(void* pObj, FINALIZERPROC pFn, void* pClientData); | |
45 void setStackBottom(void *bottom); | |
46 GC *getThreadGC(); // get apartment allocator for this thread | |
47 }; | |
48 | |
49 extern Mem mem; | |
50 | |
51 #endif /* ROOT_MEM_H */ |