From e2374c2bc74fa36db1a04c02e8014db0c62572af Mon Sep 17 00:00:00 2001 From: metahys Date: Sun, 15 Apr 2018 10:15:11 +0800 Subject: [PATCH] Update hash.cpp [bug fixes] when there is no space to insert, find() should return -1 --- hash.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hash.cpp b/hash.cpp index 4873eab..d35148f 100644 --- a/hash.cpp +++ b/hash.cpp @@ -18,9 +18,10 @@ static int find(size_t address, size_t* found_pos) { } pos = step_forward(pos); if (pos == check_pos) { - break; + return -1; } } + DEBUG_PRINT("find address:%lu pos:%lu, is found:%d\n", address, pos, found); *found_pos = pos; return found;