various minor fixes to wxHashMap: compilation warnings suppressed, use calloc() instead of new[]

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@13954 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2002-02-01 14:58:55 +00:00
parent e05c8fa7bb
commit 376e1129f7
2 changed files with 70 additions and 47 deletions

View File

@@ -2,7 +2,7 @@
// Name: hashmap.cpp
// Purpose: wxHashMap implementation
// Author: Mattia Barbon
// Modified by:
// Modified by:
// Created: 29/01/2002
// RCS-ID: $Id$
// Copyright: (c) Mattia Barbon
@@ -22,8 +22,6 @@
#include "wx/hashmap.h"
#include <assert.h>
/* FYI: This is the "One-at-a-Time" algorithm by Bob Jenkins */
/* from requirements by Colin Plumb. */
/* (http://burtleburtle.net/bob/hash/doobs.html) */
@@ -63,7 +61,7 @@ unsigned long wxStringHash::charStringHash( const char* k )
#endif
/* from SGI STL */
const unsigned long _wxHashTableBase2::s_primes[prime_count] =
const unsigned long _wxHashTableBase2::ms_primes[prime_count] =
{
7ul, 13ul, 29ul,
53ul, 97ul, 193ul, 389ul, 769ul,
@@ -76,7 +74,7 @@ const unsigned long _wxHashTableBase2::s_primes[prime_count] =
unsigned long _wxHashTableBase2::GetNextPrime( unsigned long n )
{
const unsigned long* ptr = &s_primes[0];
const unsigned long* ptr = &ms_primes[0];
for( size_t i = 0; i < prime_count; ++i, ++ptr )
{
if( n < *ptr )
@@ -84,14 +82,15 @@ unsigned long _wxHashTableBase2::GetNextPrime( unsigned long n )
}
/* someone might try to alloc a 2^32-element hash table */
assert(0);
wxFAIL_MSG( _T("hash table too big?") );
/* quiet warning */
return 0;
}
unsigned long _wxHashTableBase2::GetPreviousPrime( unsigned long n )
{
const unsigned long* ptr = &s_primes[prime_count - 1];
const unsigned long* ptr = &ms_primes[prime_count - 1];
for( size_t i = 0; i < prime_count; ++i, --ptr )
{