summaryrefslogtreecommitdiffstats
path: root/src/bplist.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/bplist.c')
-rw-r--r--src/bplist.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/bplist.c b/src/bplist.c
index 3ba46a2..bb73b31 100644
--- a/src/bplist.c
+++ b/src/bplist.c
@@ -735,7 +735,7 @@ static unsigned int plist_data_hash(const void* key)
735 case PLIST_KEY: 735 case PLIST_KEY:
736 case PLIST_STRING: 736 case PLIST_STRING:
737 buff = data->strval; 737 buff = data->strval;
738 size = strlen(buff); 738 size = data->length;
739 break; 739 break;
740 case PLIST_DATA: 740 case PLIST_DATA:
741 case PLIST_ARRAY: 741 case PLIST_ARRAY:
@@ -752,9 +752,12 @@ static unsigned int plist_data_hash(const void* key)
752 break; 752 break;
753 } 753 }
754 754
755 //now perform hash 755 // now perform hash using djb2 hashing algorithm
756 for (i = 0; i < size; buff++, i++) 756 // see: http://www.cse.yorku.ca/~oz/hash.html
757 hash = hash << 7 ^ (*buff); 757 hash += 5381;
758 for (i = 0; i < size; buff++, i++) {
759 hash = ((hash << 5) + hash) + *buff;
760 }
758 761
759 return hash; 762 return hash;
760} 763}