mirror of
https://gitlab.com/80486DX2-66/gists
synced 2025-04-14 00:19:05 +05:30
static-vs-dynamic-mem-alloc.c: use realistic memory growth
This commit is contained in:
parent
91801fdc5a
commit
aa22481f13
@ -37,7 +37,7 @@ void dynamic_memory_allocation(uint8_t** mem) {
|
||||
perror("malloc");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
for (size_t i = 1; i < MULTIPLIER; i++) {
|
||||
for (size_t i = 1; i < MULTIPLIER; i <<= 1 /* i * 2 */) {
|
||||
uint8_t* new_memory = realloc(*mem, i * sizeof(uint8_t));
|
||||
if (new_memory == NULL) {
|
||||
perror("realloc");
|
||||
|
Loading…
x
Reference in New Issue
Block a user