aboutsummaryrefslogtreecommitdiff
path: root/src/hashfunctionstring.cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-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