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

Function GC_alloc_large

v2/engine/boehm_gc/malloc.c:41–76  ·  view source on GitHub ↗

Allocate a large block of size lb bytes. */ The block is not cleared. */ Flags is 0 or IGNORE_OFF_PAGE. */ We hold the allocation lock. */ EXTRA_BYTES were already added to lb. */

Source from the content-addressed store, hash-verified

39/* We hold the allocation lock. */
40/* EXTRA_BYTES were already added to lb. */
41ptr_t GC_alloc_large(size_t lb, int k, unsigned flags)
42{
43 struct hblk * h;
44 word n_blocks;
45 ptr_t result;
46
47 /* Round up to a multiple of a granule. */
48 lb = (lb + GRANULE_BYTES - 1) & ~(GRANULE_BYTES - 1);
49 n_blocks = OBJ_SZ_TO_BLOCKS(lb);
50 if (!GC_is_initialized) GC_init_inner();
51 /* Do our share of marking work */
52 if(GC_incremental && !GC_dont_gc)
53 GC_collect_a_little_inner((int)n_blocks);
54 h = GC_allochblk(lb, k, flags);
55# ifdef USE_MUNMAP
56 if (0 == h) {
57 GC_merge_unmapped();
58 h = GC_allochblk(lb, k, flags);
59 }
60# endif
61 while (0 == h && GC_collect_or_expand(n_blocks, (flags != 0))) {
62 h = GC_allochblk(lb, k, flags);
63 }
64 if (h == 0) {
65 result = 0;
66 } else {
67 size_t total_bytes = n_blocks * HBLKSIZE;
68 if (n_blocks > 1) {
69 GC_large_allocd_bytes += total_bytes;
70 if (GC_large_allocd_bytes > GC_max_large_allocd_bytes)
71 GC_max_large_allocd_bytes = GC_large_allocd_bytes;
72 }
73 result = h -> hb_body;
74 }
75 return result;
76}
77
78
79/* Allocate a large block of size lb bytes. Clear if appropriate. */

Callers 3

GC_alloc_large_and_clearFunction · 0.85
GC_generic_mallocFunction · 0.85

Calls 5

GC_init_innerFunction · 0.85
GC_allochblkFunction · 0.85
GC_merge_unmappedFunction · 0.85
GC_collect_or_expandFunction · 0.85

Tested by

no test coverage detected