celix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Pepijn Noltes (JIRA)" <j...@apache.org>
Subject [jira] [Closed] (CELIX-348) The utils_stringHash does not generate unique hashes.
Date Tue, 05 Apr 2016 15:18:25 GMT

     [ https://issues.apache.org/jira/browse/CELIX-348?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Pepijn Noltes closed CELIX-348.
-------------------------------

> 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)

Mime
View raw message