Re: [Vala] FNV Hash algorithm



Solved only my making C library and calling via Vapi file =\

What  is  the  equivalent of this C code in vala (For utf8 string also
should work)?

typedef u_int64_t Fnv64_t;
#define FNV_64_INIT ((Fnv64_t)0x84222325cbf29ce4ULL)
#define FNV_64_PRIME ((Fnv64_t)0x100000001b3ULL)

Fnv64_t
fnv_64_str(char *str)
{
        Fnv64_t hval = FNV_64_INIT;
    unsigned char *s = (unsigned char *)str;

    while (*s) {
                hval *= FNV_64_PRIME;
                hval ^= (Fnv64_t)*s++;
    }

    return hval;
}






[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]