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

Function GC_scratch_alloc

v2/engine/boehm_gc/headers.c:114–156  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

112/* GC_scratch_end_ptr is end point of current scratch area. */
113
114ptr_t GC_scratch_alloc(size_t bytes)
115{
116 register ptr_t result = scratch_free_ptr;
117
118 bytes += GRANULE_BYTES-1;
119 bytes &= ~(GRANULE_BYTES-1);
120 scratch_free_ptr += bytes;
121 if (scratch_free_ptr <= GC_scratch_end_ptr) {
122 return(result);
123 }
124 {
125 word bytes_to_get = MINHINCR * HBLKSIZE;
126
127 if (bytes_to_get <= bytes) {
128 /* Undo the damage, and get memory directly */
129 bytes_to_get = bytes;
130# ifdef USE_MMAP
131 bytes_to_get += GC_page_size - 1;
132 bytes_to_get &= ~(GC_page_size - 1);
133# endif
134 result = (ptr_t)GET_MEM(bytes_to_get);
135 scratch_free_ptr -= bytes;
136 GC_scratch_last_end_ptr = result + bytes;
137 return(result);
138 }
139 result = (ptr_t)GET_MEM(bytes_to_get);
140 if (result == 0) {
141 if (GC_print_stats)
142 GC_printf("Out of memory - trying to allocate less\n");
143 scratch_free_ptr -= bytes;
144 bytes_to_get = bytes;
145# ifdef USE_MMAP
146 bytes_to_get += GC_page_size - 1;
147 bytes_to_get &= ~(GC_page_size - 1);
148# endif
149 return((ptr_t)GET_MEM(bytes_to_get));
150 }
151 scratch_free_ptr = result;
152 GC_scratch_end_ptr = scratch_free_ptr + bytes_to_get;
153 GC_scratch_last_end_ptr = GC_scratch_end_ptr;
154 return(GC_scratch_alloc(bytes));
155 }
156}
157
158static hdr * hdr_free_list = 0;
159

Callers 11

GC_add_map_entryFunction · 0.85
alloc_hdrFunction · 0.85
GC_init_headersFunction · 0.85
get_indexFunction · 0.85
GC_get_mapsFunction · 0.85
GC_dirty_initFunction · 0.85
GC_read_dirtyFunction · 0.85
GC_alloc_reclaim_listFunction · 0.85
alloc_mark_stackFunction · 0.85
GC_bl_initFunction · 0.85

Calls 1

GC_printfFunction · 0.85

Tested by

no test coverage detected