Browse Source

* ensure that the power-of-2 size of the hash table is always larger than
the parameter initially passed to TFPHashList.SetCapacity after r15516
(mantis #16834)

git-svn-id: trunk@15521 -

Jonas Maebe 15 years ago
parent
commit
434a6f6ee8
1 changed files with 1 additions and 1 deletions
  1. 1 1
      compiler/cclasses.pas

+ 1 - 1
compiler/cclasses.pas

@@ -1201,7 +1201,7 @@ var
 begin
 begin
   { use a power of two to be able to quickly calculate the hash table index }
   { use a power of two to be able to quickly calculate the hash table index }
   if NewCapacity <> 0 then
   if NewCapacity <> 0 then
-    NewCapacity := nextpowerof2(NewCapacity div MaxItemsPerHash, power) * MaxItemsPerHash;
+    NewCapacity := nextpowerof2((NewCapacity+(MaxItemsPerHash-1)) div MaxItemsPerHash, power) * MaxItemsPerHash;
   if (NewCapacity < FCount) or (NewCapacity > MaxHashListSize) then
   if (NewCapacity < FCount) or (NewCapacity > MaxHashListSize) then
      Error (SListCapacityError, NewCapacity);
      Error (SListCapacityError, NewCapacity);
   if NewCapacity = FCapacity then
   if NewCapacity = FCapacity then