1
0
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:
パチュリー・ノーレッジ 2025-03-02 13:12:50 +03:00
parent 91801fdc5a
commit aa22481f13
Signed by: 80486DX2-66
GPG Key ID: 83631EF27054609B

@ -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");