X-Git-Url: http://ftp.carnet.hr/carnet-debian/scm?a=blobdiff_plain;ds=sidebyside;f=src%2Fheaders%2Fhash_op.h;h=8b27ad0accc7e6f1aff2ab96d8a2ecf536ffc979;hb=3f728675941dc69d4e544d3a880a56240a6e394a;hp=9b0777a4b64bec2e5e79282c38dcb85dfd2bbbd7;hpb=927951d1c1ad45ba9e7325f07d996154a91c911b;p=ossec-hids.git diff --git a/src/headers/hash_op.h b/src/headers/hash_op.h old mode 100755 new mode 100644 index 9b0777a..8b27ad0 --- a/src/headers/hash_op.h +++ b/src/headers/hash_op.h @@ -1,6 +1,3 @@ -/* @(#) $Id: ./src/headers/hash_op.h, 2011/09/08 dcid Exp $ - */ - /* Copyright (C) 2009 Trend Micro Inc. * All rights reserved. * @@ -8,75 +5,53 @@ * and/or modify it under the terms of the GNU General Public * License (version 2) as published by the FSF - Free Software * Foundation. - * - * License details at the LICENSE file included with OSSEC or - * online at: http://www.ossec.net/en/licensing.html */ -/* Common API for dealing with directory trees */ - +/* Common API for dealing with hash operations */ #ifndef _OS_HASHOP #define _OS_HASHOP - /* Node structure */ -typedef struct _OSHashNode -{ +typedef struct _OSHashNode { struct _OSHashNode *next; - void *key; + char *key; void *data; -}OSHashNode; - +} OSHashNode; -typedef struct _OSHash -{ +typedef struct _OSHash { unsigned int rows; unsigned int initial_seed; unsigned int constant; OSHashNode **table; -}OSHash; - - +} OSHash; -/** Prototypes **/ +/* Prototypes */ +/* Create and initialize hash */ +OSHash *OSHash_Create(void); -/** OSHash *OSHash_Create(); - * Creates and initializes hash. - */ -OSHash *OSHash_Create(); - - - -/** void *OSHash_Free(OSHash *self) - * Frees the memory used by the hash. - */ -void *OSHash_Free(OSHash *self); - +/* Free the memory used by the hash */ +void *OSHash_Free(OSHash *self) __attribute__((nonnull)); - -/** void OSHash_Add(OSHash *hash, char *key, void *data) - * Returns 0 on error. +/* Returns 0 on error * Returns 1 on duplicated key (not added) * Returns 2 on success - * Key must not be NULL. + * Key must not be NULL */ -int OSHash_Add(OSHash *hash, char *key, void *data); -int OSHash_Update(OSHash *hash, char *key, void *data); - +int OSHash_Add(OSHash *hash, const char *key, void *data) __attribute__((nonnull(1, 2))); +int OSHash_Update(OSHash *hash, const char *key, void *data) __attribute__((nonnull(1, 2))); +void *OSHash_Delete(OSHash *self, const char *key) __attribute__((nonnull)); -/** void *OSHash_Get(OSHash *self, char *key) - * Returns NULL on error (key not found). - * Returns the key otherwise. - * Key must not be NULL. +/* Returns NULL on error (key not found) + * Returns the key otherwise + * Key must not be NULL */ -void *OSHash_Get(OSHash *self, char *key); +void *OSHash_Get(const OSHash *self, const char *key) __attribute__((nonnull)); -int OSHash_setSize(OSHash *self, int new_size); +int OSHash_setSize(OSHash *self, unsigned int new_size) __attribute__((nonnull)); #endif -/* EOF */