1 /* Copyright (C) 2009 Trend Micro Inc.
4 * This program is a free software; you can redistribute it
5 * and/or modify it under the terms of the GNU General Public
6 * License (version 2) as published by the FSF - Free Software
10 /* Common API for dealing with hash operations */
16 typedef struct _OSHashNode {
17 struct _OSHashNode *next;
23 typedef struct _OSHash {
25 unsigned int initial_seed;
26 unsigned int constant;
33 /* Create and initialize hash */
34 OSHash *OSHash_Create(void);
36 /* Free the memory used by the hash */
37 void *OSHash_Free(OSHash *self) __attribute__((nonnull));
40 * Returns 1 on duplicated key (not added)
41 * Returns 2 on success
42 * Key must not be NULL
44 int OSHash_Add(OSHash *hash, const char *key, void *data) __attribute__((nonnull(1, 2)));
45 int OSHash_Update(OSHash *hash, const char *key, void *data) __attribute__((nonnull(1, 2)));
46 void *OSHash_Delete(OSHash *self, const char *key) __attribute__((nonnull));
48 /* Returns NULL on error (key not found)
49 * Returns the key otherwise
50 * Key must not be NULL
52 void *OSHash_Get(const OSHash *self, const char *key) __attribute__((nonnull));
54 int OSHash_setSize(OSHash *self, unsigned int new_size) __attribute__((nonnull));