bucketLib.h

A hash table. Do not use for new code.

A hash table for which keys may be unsigned integers, pointers, or strings. This API is used by the IOC’s Channel Access Server, but it should not be used by other code.

Author

Jeffrey O. Hill

Note

Storage for identifiers must persist until an item is deleted

Status values returned by some bucketLib functions

BUCKET_SUCCESS

A synonym for S_bucket_success.

S_bucket_success

Success, must be 0.

S_bucket_noMemory

Memory allocation failed.

S_bucket_idInUse

Identifier already in use.

S_bucket_uknId

Unknown identifier.

Typedefs

typedef unsigned BUCKETID

Internal: bucket identifier.

Enums

enum buckTypeOfId

Internal: bucket key type.

Values:

enumerator bidtUnsigned
enumerator bidtPointer
enumerator bidtString

Functions

BUCKET *bucketCreate(unsigned nHashTableEntries)

Creates a new hash table.

Parameters:

nHashTableEntries – Table size

Returns:

Pointer to the newly created hash table, or NULL.

int bucketFree(BUCKET *prb)

Release memory used by a hash table.

Note

All items must be deleted from the hash table before calling this.

Parameters:

*prb – Pointer to the hash table

Returns:

S_bucket_success

int bucketShow(BUCKET *prb)

Display information about a hash table.

Parameters:

*prb – Pointer to the hash table

Returns:

S_bucket_success

int bucketAddItemUnsignedId(BUCKET *prb, const unsigned *pId, const void *pApp)

Add an item identified by an unsigned int to the table.

Parameters:
  • *prb – Pointer to the hash table

  • *pId – Pointer to the identifier

  • *pApp – Pointer to the payload

Returns:

Status value

int bucketAddItemPointerId(BUCKET *prb, void *const *pId, const void *pApp)

Add an item identified by a pointer to the table.

Parameters:
  • *prb – Pointer to the hash table

  • *pId – Pointer to the identifier

  • *pApp – Pointer to the payload

Returns:

Status value

int bucketAddItemStringId(BUCKET *prb, const char *pId, const void *pApp)

Add an item identified by a string to the table.

Parameters:
  • *prb – Pointer to the hash table

  • *pId – Pointer to the identifier

  • *pApp – Pointer to the payload

Returns:

Status value

int bucketRemoveItemUnsignedId(BUCKET *prb, const unsigned *pId)

Remove an item identified by a string from the table.

Parameters:
  • *prb – Pointer to the hash table

  • *pId – Pointer to the identifier

Returns:

Status value

int bucketRemoveItemPointerId(BUCKET *prb, void *const *pId)

Remove an item identified by a pointer from the table.

Parameters:
  • *prb – Pointer to the hash table

  • *pId – Pointer to the identifier

Returns:

Status value

int bucketRemoveItemStringId(BUCKET *prb, const char *pId)

Remove an item identified by a string from the table.

Parameters:
  • *prb – Pointer to the hash table

  • *pId – Pointer to the identifier

Returns:

Status value

void *bucketLookupItemUnsignedId(BUCKET *prb, const unsigned *pId)

Find an item identified by an unsigned int in the table.

Parameters:
  • *prb – Pointer to the hash table

  • *pId – Pointer to the identifier

Returns:

Item’s payload pointer, or NULL if not found

void *bucketLookupItemPointerId(BUCKET *prb, void *const *pId)

Find an item identified by a pointer in the table.

Parameters:
  • *prb – Pointer to the hash table

  • *pId – Pointer to the identifier

Returns:

Item’s payload pointer, or NULL if not found

void *bucketLookupItemStringId(BUCKET *prb, const char *pId)

Find an item identified by a string in the table.

Parameters:
  • *prb – Pointer to the hash table

  • *pId – Pointer to the identifier

Returns:

Item’s payload pointer, or NULL if not found

void *bucketLookupAndRemoveItemUnsignedId(BUCKET *prb, const unsigned *pId)

Find and delete an item identified by an unsigned int from the table.

Parameters:
  • *prb – Pointer to the hash table

  • *pId – Pointer to the identifier

Returns:

Item’s payload pointer, or NULL if not found

void *bucketLookupAndRemoveItemPointerId(BUCKET *prb, void *const *pId)

Find and delete an item identified by a pointer from the table.

Parameters:
  • *prb – Pointer to the hash table

  • *pId – Pointer to the identifier

Returns:

Item’s payload pointer, or NULL if not found

void *bucketLookupAndRemoveItemStringId(BUCKET *prb, const char *pId)

Find and delete an item identified by a string from the table.

Parameters:
  • *prb – Pointer to the hash table

  • *pId – Pointer to the identifier

Returns:

Item’s payload pointer, or NULL if not found

struct ITEM
#include <bucketLib.h>

Internal: bucket item structure.

Public Members

struct item *pItem
const void *pId
const void *pApp
buckTypeOfId type
struct BUCKET
#include <bucketLib.h>

Internal: Hash table structure.

Public Members

ITEM **pTable
void *freeListPVT
unsigned hashIdMask
unsigned hashIdNBits
unsigned nInUse