celix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Roy Lenferink (JIRA)" <j...@apache.org>
Subject [jira] [Resolved] (CELIX-391) The utils_stringHash does not generate unique hashes.
Date Fri, 13 Jan 2017 08:46:26 GMT

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

Roy Lenferink resolved CELIX-391.
---------------------------------
    Resolution: Fixed

> The utils_stringHash does not generate unique hashes.
> -----------------------------------------------------
>
>                 Key: CELIX-391
>                 URL: https://issues.apache.org/jira/browse/CELIX-391
>             Project: Celix
>          Issue Type: Bug
>            Reporter: Roy Lenferink
>            Priority: Minor
>         Attachments: utils_stringHash bug.png
>
>
> The utils_stringHash function is generating the same id for a set of different strings.
> The following code can be used (the DJB2 Hash algorithm):
> --------------------------------------------
> unsigned int hc = 5381;
> char ch;
> while((ch = *string++) != '\0') {
>         hc = (hc << 5) + hc + ch;
> }
> return hc;
> ---------------------------------------------
> See: http://www.cse.yorku.ca/~oz/hash.html



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

Mime
View raw message