]> git.sur5r.net Git - cc65/blobdiff - src/common/hashstr.c
Make much more usage of dynamic strings (StrBufs) instead of char* and
[cc65] / src / common / hashstr.c
index 0d2eb057277e0126c9f927c7f1559eae78e14788..4b50731c323b9fa60b2fce5c1c73336980882062 100644 (file)
@@ -6,10 +6,10 @@
 /*                                                                           */
 /*                                                                           */
 /*                                                                           */
-/* (C) 1998     Ullrich von Bassewitz                                        */
-/*              Wacholderweg 14                                              */
-/*              D-70597 Stuttgart                                            */
-/* EMail:       uz@musoftware.de                                             */
+/* (C) 1998-2008  Ullrich von Bassewitz                                      */
+/*                Roemerstrasse 52                                           */
+/*                D-70794 Filderstadt                                        */
+/* EMail:         uz@cc65.org                                                */
 /*                                                                           */
 /*                                                                           */
 /* This software is provided 'as-is', without any expressed or implied       */
 
 
 
+/* common */
+#include "hashstr.h"
+
+
+
 /*****************************************************************************/
 /*                                          Code                                    */
 /*****************************************************************************/
@@ -54,3 +59,18 @@ unsigned HashStr (const char* S)
 
 
 
+unsigned HashBuf (const StrBuf* S)
+/* Return a hash value for the given string buffer */
+{
+    unsigned I, L, H;
+
+    /* Do the hash */
+    H = L = 0;
+    for (I = 0; I < SB_GetLen (S); ++I) {
+       H = ((H << 3) ^ ((unsigned char) SB_AtUnchecked (S, I))) + L++;
+    }
+    return H;
+}
+
+
+