MCPcopy Create free account
hub / github.com/boostorg/build / GC_generic_malloc

Function GC_generic_malloc

v2/engine/boehm_gc/malloc.c:150–197  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

148}
149
150void * GC_generic_malloc(size_t lb, int k)
151{
152 void * result;
153 DCL_LOCK_STATE;
154
155 if (GC_have_errors) GC_print_all_errors();
156 GC_INVOKE_FINALIZERS();
157 if (SMALL_OBJ(lb)) {
158 LOCK();
159 result = GC_generic_malloc_inner((word)lb, k);
160 UNLOCK();
161 } else {
162 size_t lw;
163 size_t lb_rounded;
164 word n_blocks;
165 GC_bool init;
166 lw = ROUNDED_UP_WORDS(lb);
167 lb_rounded = WORDS_TO_BYTES(lw);
168 n_blocks = OBJ_SZ_TO_BLOCKS(lb_rounded);
169 init = GC_obj_kinds[k].ok_init;
170 LOCK();
171 result = (ptr_t)GC_alloc_large(lb_rounded, k, 0);
172 if (0 != result) {
173 if (GC_debugging_started) {
174 BZERO(result, n_blocks * HBLKSIZE);
175 } else {
176# ifdef THREADS
177 /* Clear any memory that might be used for GC descriptors */
178 /* before we release the lock. */
179 ((word *)result)[0] = 0;
180 ((word *)result)[1] = 0;
181 ((word *)result)[lw-1] = 0;
182 ((word *)result)[lw-2] = 0;
183# endif
184 }
185 }
186 GC_bytes_allocd += lb_rounded;
187 UNLOCK();
188 if (init && !GC_debugging_started && 0 != result) {
189 BZERO(result, n_blocks * HBLKSIZE);
190 }
191 }
192 if (0 == result) {
193 return((*GC_oom_fn)(lb));
194 } else {
195 return(result);
196 }
197}
198
199
200#define GENERAL_MALLOC(lb,k) \

Calls 3

GC_print_all_errorsFunction · 0.85
GC_generic_malloc_innerFunction · 0.85
GC_alloc_largeFunction · 0.85

Tested by

no test coverage detected