You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@celix.apache.org by "ASF GitHub Bot (JIRA)" <ji...@apache.org> on 2017/01/12 07:53:52 UTC

[jira] [Commented] (CELIX-391) The utils_stringHash does not generate unique hashes.

    [ https://issues.apache.org/jira/browse/CELIX-391?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15820414#comment-15820414 ] 

ASF GitHub Bot commented on CELIX-391:
--------------------------------------

GitHub user rlenferink opened a pull request:

    https://github.com/apache/celix/pull/13

    CELIX-391: Fix for utils_stringHash

    

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/rlenferink/celix develop

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/celix/pull/13.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #13
    
----
commit 3824cfc3d5bc6fd0b20c284eed3164294ad5a92c
Author: Roy Lenferink <le...@gmail.com>
Date:   2017-01-12T07:51:39Z

    CELIX-391: Fix for utils_stringHash

----


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