Last active
December 12, 2015 06:59
-
-
Save vanhoefm/4733332 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static void* _int_malloc(mstate av, size_t bytes) | |
{ | |
INTERNAL_SIZE_T nb; /* normalized request size */ | |
mchunkptr victim; /* inspected/selected chunk */ | |
INTERNAL_SIZE_T size; /* its size */ | |
mchunkptr remainder; /* remainder from a split */ | |
unsigned long remainder_size; /* its size */ | |
checked_request2size(bytes, nb); | |
[...] | |
victim = av->top; | |
size = chunksize(victim); | |
if ((unsigned long)(size) >= (unsigned long)(nb + MINSIZE)) | |
{ | |
remainder_size = size - nb; | |
remainder = chunk_at_offset(victim, nb); | |
av->top = remainder; | |
set_head(victim, nb | PREV_INUSE | (av!=&main_arena ? NON_MAIN_ARENA : 0)); | |
set_head(remainder, remainder_size | PREV_INUSE); | |
check_malloced_chunk(av, victim, nb); | |
void *p = chunk2mem(victim); | |
if (__builtin_expect (perturb_byte, 0)) | |
alloc_perturb (p, bytes); | |
return p; | |
} | |
[...] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment