Erjan Altena created CELIX-348:
----------------------------------

             Summary: The utils_stringHash does not generate unique hashes.
                 Key: CELIX-348
                 URL: https://issues.apache.org/jira/browse/CELIX-348
             Project: Celix
          Issue Type: Improvement
          Components: Framework
    Affects Versions: next
            Reporter: Erjan Altena


Using the utils_stringHash functions on a few 100 strings, it generates the 
same hash for different strings. Of course the hash function can not be 
guaranteed to deliver unique hashes but the uniqueness can be improved by the 
next calculation (the DJB2 Hash algorithm)


unsigned int hash = 5381;
unsigned int i = 0;
unsigned int len = strlen(string);

for(i=0; i < len; i++) {
        hash = (hash << 5) + (*string) + hash;
}

return hash;




--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to