Mercurial > projects > ldc
comparison dmd/mem.c @ 6:35d93ce68cf4 trunk
[svn r10] Updated for LLVM rev. 20070913
Applied fixes from wilsonk on the forum
Some tweaks to work with gc 7.0
Fixed aggregate members of aggregates
Fixed cyclic/recursive class declarations
Other minor tweaks
author | lindquist |
---|---|
date | Wed, 26 Sep 2007 19:05:18 +0200 |
parents | c53b6e3fe49a |
children | 23d0d9855cad |
comparison
equal
deleted
inserted
replaced
5:3d60e549b0c2 | 6:35d93ce68cf4 |
---|---|
4 | 4 |
5 #include <stdio.h> | 5 #include <stdio.h> |
6 #include <stdlib.h> | 6 #include <stdlib.h> |
7 #include <string.h> | 7 #include <string.h> |
8 | 8 |
9 #include "gc.h" | 9 // I needed to perfix the dir after upgrading to gc 7.0 |
10 #include "gc/gc.h" | |
10 | 11 |
11 #include "mem.h" | 12 #include "mem.h" |
12 | 13 |
13 /* This implementation of the storage allocator uses the standard C allocation package. | 14 /* This implementation of the storage allocator uses the standard C allocation package. |
14 */ | 15 */ |
15 | 16 |
16 Mem mem; | 17 Mem mem; |
18 static bool gc_was_init = false; | |
17 | 19 |
18 void Mem::init() | 20 void Mem::init() |
19 { | 21 { |
20 GC_init(); | 22 GC_init(); |
23 gc_was_init = true; | |
21 } | 24 } |
22 | 25 |
23 char *Mem::strdup(const char *s) | 26 char *Mem::strdup(const char *s) |
24 { | 27 { |
25 char *p; | 28 char *p; |
125 } | 128 } |
126 | 129 |
127 /* =================================================== */ | 130 /* =================================================== */ |
128 | 131 |
129 void * operator new(size_t m_size) | 132 void * operator new(size_t m_size) |
130 { | 133 { |
134 // without this we segfault with gc 7.0 | |
135 if (!gc_was_init) { | |
136 mem.init(); | |
137 } | |
131 void *p = GC_malloc(m_size); | 138 void *p = GC_malloc(m_size); |
132 if (p) | 139 if (p) |
133 return p; | 140 return p; |
134 printf("Error: out of memory\n"); | 141 printf("Error: out of memory\n"); |
135 exit(EXIT_FAILURE); | 142 exit(EXIT_FAILURE); |