Fixed a divide by zero error in the hash functions
This commit is contained in:
parent
b251880d8b
commit
b8bef29bcc
|
@ -167,7 +167,13 @@ u64 GetMurmurHash3(const u8 *src, int len, u32 samples)
|
||||||
const u8 * data = (const u8*)src;
|
const u8 * data = (const u8*)src;
|
||||||
const int nblocks = len / 16;
|
const int nblocks = len / 16;
|
||||||
u32 Step = (len / 8);
|
u32 Step = (len / 8);
|
||||||
if(samples == 0) samples = Step;
|
if(samples == 0)
|
||||||
|
{
|
||||||
|
if (Step == 0)
|
||||||
|
samples = 1;
|
||||||
|
else
|
||||||
|
samples = Step;
|
||||||
|
}
|
||||||
Step = Step / samples;
|
Step = Step / samples;
|
||||||
if(Step < 1) Step = 1;
|
if(Step < 1) Step = 1;
|
||||||
|
|
||||||
|
@ -245,7 +251,13 @@ u64 GetCRC32(const u8 *src, int len, u32 samples)
|
||||||
u32 Step = (len / 8);
|
u32 Step = (len / 8);
|
||||||
const u64 *data = (const u64 *)src;
|
const u64 *data = (const u64 *)src;
|
||||||
const u64 *end = data + Step;
|
const u64 *end = data + Step;
|
||||||
if(samples == 0) samples = Step;
|
if(samples == 0)
|
||||||
|
{
|
||||||
|
if (Step == 0)
|
||||||
|
samples = 1;
|
||||||
|
else
|
||||||
|
samples = Step;
|
||||||
|
}
|
||||||
Step = Step / samples;
|
Step = Step / samples;
|
||||||
if(Step < 1) Step = 1;
|
if(Step < 1) Step = 1;
|
||||||
while(data < end)
|
while(data < end)
|
||||||
|
@ -275,7 +287,13 @@ u64 GetHashHiresTexture(const u8 *src, int len, u32 samples)
|
||||||
u32 Step = (len / 8);
|
u32 Step = (len / 8);
|
||||||
const u64 *data = (const u64 *)src;
|
const u64 *data = (const u64 *)src;
|
||||||
const u64 *end = data + Step;
|
const u64 *end = data + Step;
|
||||||
if(samples == 0) samples = Step;
|
if(samples == 0)
|
||||||
|
{
|
||||||
|
if (Step == 0)
|
||||||
|
samples = 1;
|
||||||
|
else
|
||||||
|
samples = Step;
|
||||||
|
}
|
||||||
Step = Step / samples;
|
Step = Step / samples;
|
||||||
if(Step < 1) Step = 1;
|
if(Step < 1) Step = 1;
|
||||||
while(data < end)
|
while(data < end)
|
||||||
|
@ -318,7 +336,13 @@ u64 GetCRC32(const u8 *src, int len, u32 samples)
|
||||||
u32 Step = (len/4);
|
u32 Step = (len/4);
|
||||||
const u32 *data = (const u32 *)src;
|
const u32 *data = (const u32 *)src;
|
||||||
const u32 *end = data + Step;
|
const u32 *end = data + Step;
|
||||||
if(samples == 0) samples = Step;
|
if(samples == 0)
|
||||||
|
{
|
||||||
|
if (Step == 0)
|
||||||
|
samples = 1;
|
||||||
|
else
|
||||||
|
samples = Step;
|
||||||
|
}
|
||||||
Step = Step / samples;
|
Step = Step / samples;
|
||||||
if(Step < 1) Step = 1;
|
if(Step < 1) Step = 1;
|
||||||
while(data < end)
|
while(data < end)
|
||||||
|
@ -390,7 +414,13 @@ u64 GetMurmurHash3(const u8* src, int len, u32 samples)
|
||||||
u32 out[2];
|
u32 out[2];
|
||||||
const int nblocks = len / 8;
|
const int nblocks = len / 8;
|
||||||
u32 Step = (len / 4);
|
u32 Step = (len / 4);
|
||||||
if(samples == 0) samples = Step;
|
if(samples == 0)
|
||||||
|
{
|
||||||
|
if (Step == 0)
|
||||||
|
samples = 1;
|
||||||
|
else
|
||||||
|
samples = Step;
|
||||||
|
}
|
||||||
Step = Step / samples;
|
Step = Step / samples;
|
||||||
if(Step < 1) Step = 1;
|
if(Step < 1) Step = 1;
|
||||||
|
|
||||||
|
@ -464,7 +494,13 @@ u64 GetHashHiresTexture(const u8 *src, int len, u32 samples)
|
||||||
u32 Step = (len / 8);
|
u32 Step = (len / 8);
|
||||||
const u64 *data = (const u64 *)src;
|
const u64 *data = (const u64 *)src;
|
||||||
const u64 *end = data + Step;
|
const u64 *end = data + Step;
|
||||||
if(samples == 0) samples = Step;
|
if(samples == 0)
|
||||||
|
{
|
||||||
|
if (Step == 0)
|
||||||
|
samples = 1;
|
||||||
|
else
|
||||||
|
samples = Step;
|
||||||
|
}
|
||||||
Step = Step / samples;
|
Step = Step / samples;
|
||||||
if(Step < 1) Step = 1;
|
if(Step < 1) Step = 1;
|
||||||
while(data < end)
|
while(data < end)
|
||||||
|
|
Loading…
Reference in New Issue