kinetic-c  v0.12.0
Seagate Kinetic Protocol Client Library for C
Macros | Functions
yacht.c File Reference
#include "yacht.h"
#include "yacht_internals.h"

Go to the source code of this file.

Macros

#define LOG(...)
 
#define DEF_SZ2   4
 
#define MAX_PROBES   16
 
#define LARGE_PRIME   (4294967291L /* (2 ** 32) - 5 */)
 

Functions

static bool insert (int *buckets, void **values, size_t mask, size_t max_fill, int key, void *value, void **old_value)
 
static bool grow (struct yacht *y)
 
struct yachtYacht_Init (uint8_t sz2)
 Init a hash table with approx. More...
 
static size_t hash (int key)
 
bool Yacht_Get (struct yacht *y, int key, void **value)
 Get KEY from the table, setting *value if found. More...
 
bool Yacht_Member (struct yacht *y, int key)
 Check if KEY is in the table. More...
 
bool Yacht_Set (struct yacht *y, int key, void *value, void **old_value)
 Set KEY to VALUE in the table. More...
 
bool Yacht_Remove (struct yacht *y, int key, void **old_value)
 Remove KEY from the table. More...
 
void Yacht_Free (struct yacht *y, Yacht_Free_cb *cb, void *udata)
 Free the table. More...
 

Macro Definition Documentation

#define LOG (   ...)

Definition at line 27 of file yacht.c.

#define DEF_SZ2   4

Definition at line 37 of file yacht.c.

#define MAX_PROBES   16

Definition at line 38 of file yacht.c.

#define LARGE_PRIME   (4294967291L /* (2 ** 32) - 5 */)

Definition at line 66 of file yacht.c.

Function Documentation

static bool insert ( int *  buckets,
void **  values,
size_t  mask,
size_t  max_fill,
int  key,
void *  value,
void **  old_value 
)
static

Definition at line 111 of file yacht.c.

References hash(), LOG, yacht::mask, YACHT_DELETED, and YACHT_NO_KEY.

static bool grow ( struct yacht y)
static
struct yacht* Yacht_Init ( uint8_t  sz2)

Init a hash table with approx.

2 ** sz2 buckets.

Definition at line 41 of file yacht.c.

References yacht::buckets, DEF_SZ2, LOG, yacht::mask, yacht::size, yacht::values, and YACHT_NO_KEY.

static size_t hash ( int  key)
static

Definition at line 69 of file yacht.c.

References LARGE_PRIME.

bool Yacht_Get ( struct yacht y,
int  key,
void **  value 
)

Get KEY from the table, setting *value if found.

Definition at line 73 of file yacht.c.

References yacht::buckets, hash(), LOG, yacht::mask, yacht::size, yacht::values, YACHT_DELETED, and YACHT_NO_KEY.

bool Yacht_Member ( struct yacht y,
int  key 
)

Check if KEY is in the table.

Definition at line 91 of file yacht.c.

References LOG, and Yacht_Get().

bool Yacht_Set ( struct yacht y,
int  key,
void *  value,
void **  old_value 
)

Set KEY to VALUE in the table.

Definition at line 97 of file yacht.c.

References yacht::buckets, grow(), insert(), LOG, yacht::mask, MAX_PROBES, yacht::size, and yacht::values.

bool Yacht_Remove ( struct yacht y,
int  key,
void **  old_value 
)

Remove KEY from the table.

RetuBus_RegisterSocket the old value in *old_value, if non-NULL.

Definition at line 174 of file yacht.c.

References yacht::buckets, hash(), LOG, yacht::mask, yacht::size, yacht::values, YACHT_DELETED, and YACHT_NO_KEY.

void Yacht_Free ( struct yacht y,
Yacht_Free_cb cb,
void *  udata 
)

Free the table.

Definition at line 202 of file yacht.c.

References yacht::buckets, yacht::size, yacht::values, YACHT_DELETED, and YACHT_NO_KEY.