From c58c458dc919104958454f33e6887791e5965a33 Mon Sep 17 00:00:00 2001 From: Michal Zidek Date: Wed, 14 Aug 2013 18:22:06 +0200 Subject: mmap_cache: Off by one error. Removes off by one error when using macro MC_SIZE_TO_SLOTS and adds new macro MC_SLOT_WITHIN_BOUNDS. --- src/util/mmap_cache.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/util') diff --git a/src/util/mmap_cache.h b/src/util/mmap_cache.h index 6c223df6c..abf8cac49 100644 --- a/src/util/mmap_cache.h +++ b/src/util/mmap_cache.h @@ -67,6 +67,9 @@ typedef uint32_t rel_ptr_t; #define MC_SLOT_TO_PTR(base, slot, type) \ (type *)((base) + ((slot) * MC_SLOT_SIZE)) +#define MC_SLOT_WITHIN_BOUNDS(slot, dt_size) \ + ((slot) < ((dt_size) / MC_SLOT_SIZE)) + #define MC_VALID_BARRIER(val) (((val) & 0xff000000) == 0xf0000000) #define MC_CHECK_RECORD_LENGTH(mc_ctx, rec) \ -- cgit