From 30869eede9508eab23a46fe6e3fb409d9d0bff5a Mon Sep 17 00:00:00 2001 From: Avril Date: Fri, 11 Dec 2020 14:46:51 +0000 Subject: [PATCH] day11-part1: reduce memory usage --- day11/day11.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/day11/day11.c b/day11/day11.c index 2034d6d..8e71b17 100644 --- a/day11/day11.c +++ b/day11/day11.c @@ -120,11 +120,10 @@ static inline int gol_eq(const gol_t* g1, const gol_t* g2) return memcmp(g1->arena, g2->arena, sizeof(g1->arena))==0; } -gol_t simulate_once(const gol_t* source) +static inline gol_t simulate_once(const gol_t* from) { - gol_t out = *source; - simulate_ip(source, &out); - + gol_t out; + simulate_ip(from, &out); return out; } @@ -150,7 +149,11 @@ int main() gol_t tmp; while(1) { +#ifndef _COPY_ALLOC_ARENA + simulate_ip(arena, &tmp); +#else tmp = simulate_once(arena); +#endif #ifdef DEBUG printf("Next: \n"); print_arena(&tmp);