[BACK]Return to compat_ohash.h CVS log [TXT][DIR] Up to [cvsweb.bsd.lv] / pod2mdoc

Annotation of pod2mdoc/compat_ohash.h, Revision 1.1

1.1     ! schwarze    1: /* $Id$ */
        !             2: /* $OpenBSD: ohash.h,v 1.2 2014/06/02 18:52:03 deraadt Exp $ */
        !             3:
        !             4: /* Copyright (c) 1999, 2004 Marc Espie <espie@openbsd.org>
        !             5:  *
        !             6:  * Permission to use, copy, modify, and distribute this software for any
        !             7:  * purpose with or without fee is hereby granted, provided that the above
        !             8:  * copyright notice and this permission notice appear in all copies.
        !             9:  *
        !            10:  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
        !            11:  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
        !            12:  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
        !            13:  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
        !            14:  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
        !            15:  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
        !            16:  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
        !            17:  */
        !            18:
        !            19: /* Open hashing support.
        !            20:  * Open hashing was chosen because it is much lighter than other hash
        !            21:  * techniques, and more efficient in most cases.
        !            22:  */
        !            23:
        !            24: /* user-visible data structure */
        !            25: struct ohash_info {
        !            26:        ptrdiff_t key_offset;
        !            27:        void *data;     /* user data */
        !            28:        void *(*calloc)(size_t, size_t, void *);
        !            29:        void (*free)(void *, void *);
        !            30:        void *(*alloc)(size_t, void *);
        !            31: };
        !            32:
        !            33: struct _ohash_record;
        !            34:
        !            35: /* private structure. It's there just so you can do a sizeof */
        !            36: struct ohash {
        !            37:        struct _ohash_record    *t;
        !            38:        struct ohash_info       info;
        !            39:        unsigned int            size;
        !            40:        unsigned int            total;
        !            41:        unsigned int            deleted;
        !            42: };
        !            43:
        !            44: /* For this to be tweakable, we use small primitives, and leave part of the
        !            45:  * logic to the client application.  e.g., hashing is left to the client
        !            46:  * application.  We also provide a simple table entry lookup that yields
        !            47:  * a hashing table index (opaque) to be used in find/insert/remove.
        !            48:  * The keys are stored at a known position in the client data.
        !            49:  */
        !            50: void ohash_init(struct ohash *, unsigned, struct ohash_info *);
        !            51: void ohash_delete(struct ohash *);
        !            52:
        !            53: unsigned int ohash_lookup_interval(struct ohash *, const char *,
        !            54:            const char *, uint32_t);
        !            55: unsigned int ohash_lookup_memory(struct ohash *, const char *,
        !            56:            size_t, uint32_t);
        !            57: void *ohash_find(struct ohash *, unsigned int);
        !            58: void *ohash_remove(struct ohash *, unsigned int);
        !            59: void *ohash_insert(struct ohash *, unsigned int, void *);
        !            60: void *ohash_first(struct ohash *, unsigned int *);
        !            61: void *ohash_next(struct ohash *, unsigned int *);
        !            62: unsigned int ohash_entries(struct ohash *);
        !            63:
        !            64: void *ohash_create_entry(struct ohash_info *, const char *, const char **);
        !            65: uint32_t ohash_interval(const char *, const char **);
        !            66:
        !            67: unsigned int ohash_qlookupi(struct ohash *, const char *, const char **);
        !            68: unsigned int ohash_qlookup(struct ohash *, const char *);

CVSweb