aboutsummaryrefslogtreecommitdiff
path: root/src/hashfunctionstring.cpp
diff options
context:
space:
mode:
authorDavid <david@xagasoft.com>2006-08-30 00:34:28 +0000
committerDavid <david@xagasoft.com>2006-08-30 00:34:28 +0000
commitb797d7a7c4481c20b26ecf6ce7ef77e4782534bb (patch)
treec16d8138d6e025ed2ba0f133cef0bd9c2c322638 /src/hashfunctionstring.cpp
parent5ff43b1a4abd06a47a996b817846567f8d1bc615 (diff)
downloadlibbu++-b797d7a7c4481c20b26ecf6ce7ef77e4782534bb.tar.gz
libbu++-b797d7a7c4481c20b26ecf6ce7ef77e4782534bb.tar.bz2
libbu++-b797d7a7c4481c20b26ecf6ce7ef77e4782534bb.tar.xz
libbu++-b797d7a7c4481c20b26ecf6ce7ef77e4782534bb.zip
david - creepy forgot to commit hashtable stuff... also fixed something in md5... it was using uninitialized data...
Diffstat (limited to 'src/hashfunctionstring.cpp')
-rw-r--r--src/hashfunctionstring.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/hashfunctionstring.cpp b/src/hashfunctionstring.cpp
index 6ce7bb3..bd14643 100644
--- a/src/hashfunctionstring.cpp
+++ b/src/hashfunctionstring.cpp
@@ -1,4 +1,7 @@
1#include "hashfunctionstring.h" 1#include "hashfunctionstring.h"
2#ifndef NULL
3#define NULL ((void *) 0)
4#endif
2 5
3HashFunctionString::HashFunctionString() 6HashFunctionString::HashFunctionString()
4{ 7{
@@ -10,6 +13,11 @@ HashFunctionString::~HashFunctionString()
10 13
11unsigned long int HashFunctionString::hash( const void *id ) 14unsigned long int HashFunctionString::hash( const void *id )
12{ 15{
16 if (id == NULL)
17 {
18 return 0;
19 }
20
13 unsigned long int nPos = 0; 21 unsigned long int nPos = 0;
14 for( const char *s = (const char *)id; *s; s++ ) 22 for( const char *s = (const char *)id; *s; s++ )
15 { 23 {
@@ -20,6 +28,15 @@ unsigned long int HashFunctionString::hash( const void *id )
20 28
21bool HashFunctionString::cmpIDs( const void *id1, const void *id2 ) 29bool HashFunctionString::cmpIDs( const void *id1, const void *id2 )
22{ 30{
31 if (id1 == NULL || id2 == NULL)
32 {
33 return false;
34 }
35 if (id1 == id2)
36 {
37 return true;
38 }
39
23 const char *str1 = (const char *)id1; 40 const char *str1 = (const char *)id1;
24 const char *str2 = (const char *)id2; 41 const char *str2 = (const char *)id2;
25 42