Malloc using mmap
| 2310 | |
| 2311 | // Malloc using mmap |
| 2312 | void* malloc_state::mmap_alloc(size_t nb) |
| 2313 | { |
| 2314 | size_t mmsize = mmap_align(nb + 6 * sizeof(size_t) + spp_chunk_align_mask); |
| 2315 | if (_footprint_limit != 0) |
| 2316 | { |
| 2317 | size_t fp = _footprint + mmsize; |
| 2318 | if (fp <= _footprint || fp > _footprint_limit) |
| 2319 | return 0; |
| 2320 | } |
| 2321 | if (mmsize > nb) |
| 2322 | { |
| 2323 | // Check for wrap around 0 |
| 2324 | char* mm = (char*)(SPP_CALL_DIRECT_MMAP(mmsize)); |
| 2325 | if (mm != cmfail) |
| 2326 | { |
| 2327 | size_t offset = align_offset(chunk2mem(mm)); |
| 2328 | size_t psize = mmsize - offset - SPP_MMAP_FOOT_PAD; |
| 2329 | mchunkptr p = (mchunkptr)(mm + offset); |
| 2330 | p->_prev_foot = offset; |
| 2331 | p->_head = psize; |
| 2332 | mark_inuse_foot(p, psize); |
| 2333 | p->chunk_plus_offset(psize)->_head = FENCEPOST_HEAD; |
| 2334 | p->chunk_plus_offset(psize + sizeof(size_t))->_head = 0; |
| 2335 | |
| 2336 | if (_least_addr == 0 || mm < _least_addr) |
| 2337 | _least_addr = mm; |
| 2338 | if ((_footprint += mmsize) > _max_footprint) |
| 2339 | _max_footprint = _footprint; |
| 2340 | assert(spp_is_aligned(chunk2mem(p))); |
| 2341 | check_mmapped_chunk(p); |
| 2342 | return chunk2mem(p); |
| 2343 | } |
| 2344 | } |
| 2345 | return 0; |
| 2346 | } |
| 2347 | |
| 2348 | // Realloc using mmap |
| 2349 | mchunkptr malloc_state::mmap_resize(mchunkptr oldp, size_t nb, int flags) |
nothing calls this directly
no test coverage detected