Created
January 18, 2017 10:06
-
-
Save janjongboom/bbfb89c31db3cda135138b72a8093f64 to your computer and use it in GitHub Desktop.
malloc
This file contains hidden or 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 start_filling_up() { | |
void* buffer; | |
uint32_t allocated = 0; | |
uint32_t size = 4096; | |
while (true) { | |
if (size == 64) break; | |
buffer = malloc(size); | |
if (buffer == NULL) { | |
size = size / 2; | |
continue; | |
} | |
printf("Allocated %d bytes\n", size); | |
allocated += size; | |
wait_ms(10); | |
} | |
printf("Allocated %d bytes before failed\n", allocated); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment