struct util_cache
{
/** Hash function */
- uint32_t (*hash)(void *key);
+ uint32_t (*hash)(const void *key);
/** Compare two keys */
- int (*compare)(void *key1, void *key2);
+ int (*compare)(const void *key1, const void *key2);
/** Destroy a (key, value) pair */
void (*destroy)(void *key, void *value);
struct util_cache *
-util_cache_create(uint32_t (*hash)(void *key),
- int (*compare)(void *key1, void *key2),
- void (*destroy)(void *key, void *value),
- uint32_t size)
+util_cache_create(uint32_t (*hash)(const void *key),
+ int (*compare)(const void *key1, const void *key2),
+ void (*destroy)(void *key, void *value),
+ uint32_t size)
{
struct util_cache *cache;
static INLINE struct util_cache_entry *
util_cache_entry_get(struct util_cache *cache,
- void *key)
+ const void *key)
{
uint32_t hash;
void *
util_cache_get(struct util_cache *cache,
- void *key)
+ const void *key)
{
struct util_cache_entry *entry;
* @param size maximum number of entries
*/
struct util_cache *
-util_cache_create(uint32_t (*hash)(void *key),
- int (*compare)(void *key1, void *key2),
- void (*destroy)(void *key, void *value),
- uint32_t size);
+util_cache_create(uint32_t (*hash)(const void *key),
+ int (*compare)(const void *key1, const void *key2),
+ void (*destroy)(void *key, void *value),
+ uint32_t size);
void
util_cache_set(struct util_cache *cache,
- void *key,
- void *value);
+ void *key,
+ void *value);
void *
util_cache_get(struct util_cache *cache,
- void *key);
+ const void *key);
void
util_cache_clear(struct util_cache *cache);
#include "u_hash.h"
-static uint32_t
+static const uint32_t
util_crc32_table[256] = {
0x00000000, 0x77073096, 0xee0e612c, 0x990951ba,
0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3,
* @sa http://www.w3.org/TR/PNG/#D-CRCAppendix
*/
uint32_t
-util_hash_crc32(void *data, size_t size)
+util_hash_crc32(const void *data, size_t size)
{
uint8_t *p = (uint8_t *)data;
uint32_t crc = 0xffffffff;
uint32_t
-util_hash_crc32(void *data, size_t size);
+util_hash_crc32(const void *data, size_t size);
#ifdef __cplusplus