Blame modules/pam_console/hashtable_private.h

Packit 7e982e
/* Copyright (C) 2002, 2004 Christopher Clark <firstname.lastname@cl.cam.ac.uk> */
Packit 7e982e
Packit 7e982e
#ifndef __HASHTABLE_PRIVATE_CWC22_H__
Packit 7e982e
#define __HASHTABLE_PRIVATE_CWC22_H__
Packit 7e982e
Packit 7e982e
#include "hashtable.h"
Packit 7e982e
Packit 7e982e
/*****************************************************************************/
Packit 7e982e
struct entry
Packit 7e982e
{
Packit 7e982e
    void *k, *v;
Packit 7e982e
    unsigned int h;
Packit 7e982e
    struct entry *next;
Packit 7e982e
};
Packit 7e982e
Packit 7e982e
struct hashtable {
Packit 7e982e
    unsigned int tablelength;
Packit 7e982e
    struct entry **table;
Packit 7e982e
    unsigned int entrycount;
Packit 7e982e
    unsigned int loadlimit;
Packit 7e982e
    unsigned int primeindex;
Packit 7e982e
    unsigned int (*hashfn) (void *k);
Packit 7e982e
    int (*eqfn) (void *k1, void *k2);
Packit 7e982e
};
Packit 7e982e
Packit 7e982e
/*****************************************************************************/
Packit 7e982e
unsigned int
Packit 7e982e
hash(struct hashtable *h, void *k);
Packit 7e982e
Packit 7e982e
/*****************************************************************************/
Packit 7e982e
/* indexFor */
Packit 7e982e
static inline unsigned int
Packit 7e982e
indexFor(unsigned int tablelength, unsigned int hashvalue) {
Packit 7e982e
    return (hashvalue % tablelength);
Packit 7e982e
};
Packit 7e982e
Packit 7e982e
/* Only works if tablelength == 2^N */
Packit 7e982e
/*static inline unsigned int
Packit 7e982e
indexFor(unsigned int tablelength, unsigned int hashvalue)
Packit 7e982e
{
Packit 7e982e
    return (hashvalue & (tablelength - 1u));
Packit 7e982e
}
Packit 7e982e
*/
Packit 7e982e
Packit 7e982e
/*****************************************************************************/
Packit 7e982e
#define freekey(X) free(X)
Packit 7e982e
/*define freekey(X) ; */
Packit 7e982e
Packit 7e982e
Packit 7e982e
/*****************************************************************************/
Packit 7e982e
Packit 7e982e
#endif /* __HASHTABLE_PRIVATE_CWC22_H__*/
Packit 7e982e
Packit 7e982e
/*
Packit 7e982e
 * Copyright (c) 2002, Christopher Clark
Packit 7e982e
 * All rights reserved.
Packit 7e982e
 * 
Packit 7e982e
 * Redistribution and use in source and binary forms, with or without
Packit 7e982e
 * modification, are permitted provided that the following conditions
Packit 7e982e
 * are met:
Packit 7e982e
 * 
Packit 7e982e
 * * Redistributions of source code must retain the above copyright
Packit 7e982e
 * notice, this list of conditions and the following disclaimer.
Packit 7e982e
 * 
Packit 7e982e
 * * Redistributions in binary form must reproduce the above copyright
Packit 7e982e
 * notice, this list of conditions and the following disclaimer in the
Packit 7e982e
 * documentation and/or other materials provided with the distribution.
Packit 7e982e
 * 
Packit 7e982e
 * * Neither the name of the original author; nor the names of any contributors
Packit 7e982e
 * may be used to endorse or promote products derived from this software
Packit 7e982e
 * without specific prior written permission.
Packit 7e982e
 * 
Packit 7e982e
 * 
Packit 7e982e
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
Packit 7e982e
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
Packit 7e982e
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
Packit 7e982e
 * A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER
Packit 7e982e
 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
Packit 7e982e
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
Packit 7e982e
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
Packit 7e982e
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
Packit 7e982e
 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
Packit 7e982e
 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
Packit 7e982e
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Packit 7e982e
*/