diff options
author | Ian C <ianc@noddybox.co.uk> | 2017-05-10 09:00:28 +0000 |
---|---|---|
committer | Ian C <ianc@noddybox.co.uk> | 2017-05-10 09:00:28 +0000 |
commit | 67ebfbd2f7073647023d760807fc74cbb507f8c0 (patch) | |
tree | bcbeaa7b1254a3b651f276cc41d98b873b61d043 /dbox.c | |
parent | 241cf0478e2335744586efa5c5a283c78b9b7cdc (diff) |
Reduced memory usage.
Diffstat (limited to 'dbox.c')
-rw-r--r-- | dbox.c | 17 |
1 files changed, 7 insertions, 10 deletions
@@ -106,7 +106,6 @@ typedef struct typedef struct cache_t { const state_t *state; - map_t *map; struct cache_t *next; } cache_t; @@ -486,7 +485,6 @@ static void ClearStates(void) cache_t *p; p = g_cache[f]->next; - free(g_cache[f]->map); free(g_cache[f]); g_cache[f] = p; } @@ -583,13 +581,11 @@ static void DumpCacheDistribution(void) static int AddNewState(const level_t *p_level, const state_t *p_state) { cache_t *p; - map_t *map; map_t hash; hash = p_state->hash % CACHE_SIZE; p = g_cache[hash]; - map = CreateMap(p_level, p_state); while(p) { @@ -598,16 +594,18 @@ static int AddNewState(const level_t *p_level, const state_t *p_state) int f; map_t check; - check = 0; + check = FALSE; - for(f = 0; f < p_level->height; f++) + for(f = 0; f < p_level->no_boxes && !check; f++) { - check |= (map[f] ^ p->map[f]); + if (!FindPos(p->state->box, p_level->no_boxes, p_state->box[f])) + { + check = TRUE; + } } - if (check == 0) + if (!check) { - free(map); return FALSE; } } @@ -618,7 +616,6 @@ static int AddNewState(const level_t *p_level, const state_t *p_state) p = Grab(sizeof *p); p->state = p_state; - p->map = map; p->next = g_cache[hash]; g_cache[hash] = p; |