From 9f9fe7f0ea97f3a0b92ee532e38f7ea22151ef1a Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Wed, 2 Sep 2015 07:39:11 -0700 Subject: Slot cache fix: zero is a valid slot index. struct.c (cacheline_lookup): return -1 when the id is not found in the cacheline, rather than zero. (lookup_slot): Test return value of cacheline_lookup according to the above change. --- struct.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'struct.c') diff --git a/struct.c b/struct.c index b1920d97..491178d9 100644 --- a/struct.c +++ b/struct.c @@ -323,7 +323,7 @@ static int cache_set_lookup(slot_cache_entry_t *set, cnum id) return set[2].slot; } - return 0; + return -1; } static void cache_set_insert(slot_cache_entry_t *set, cnum id, cnum slot) @@ -352,7 +352,7 @@ static val *lookup_slot(struct struct_inst *si, val sym) slot_cache_set_t *set = &slot_cache[id % SLOT_CACHE_SIZE]; cnum slot = cache_set_lookup(*set, id); - if (slot) { + if (slot >= 0) { return &si->slot[slot]; } else { val key = cons(sym, num_fast(id)); -- cgit v1.2.3