mirror of
https://gitlab.com/80486DX2-66/gists
synced 2025-05-31 08:31:41 +05:30
static-vs-dynamic-mem-alloc.c: use realistic memory growth
This commit is contained in:
@@ -37,7 +37,7 @@ void dynamic_memory_allocation(uint8_t** mem) {
|
|||||||
perror("malloc");
|
perror("malloc");
|
||||||
exit(EXIT_FAILURE);
|
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));
|
uint8_t* new_memory = realloc(*mem, i * sizeof(uint8_t));
|
||||||
if (new_memory == NULL) {
|
if (new_memory == NULL) {
|
||||||
perror("realloc");
|
perror("realloc");
|
||||||
|
Reference in New Issue
Block a user