diff --git a/src/mapping.c b/src/mapping.c
index ddc9fecd67b709b5efeede8292ec629c0eb109a4..534a148aebcec57a73a935d7169e5b989e875632 100644
--- a/src/mapping.c
+++ b/src/mapping.c
@@ -197,6 +197,8 @@ static void init_mapping(struct mapping *m,
   {
     hashsize=find_next_power(size / AVG_LINK_LENGTH + 1);
 
+    if (size < hashsize) size = hashsize;
+
     e=MAPPING_DATA_SIZE(hashsize, size);
 
     md=xcalloc(1,e);