gwion-util
utilities for the Gwion project
Loading...
Searching...
No Matches
Functions
hash.c File Reference
#include "gwion_util.h"

Go to the source code of this file.

Functions

void hini (Hash h, const uint nmemb)
 
void hdel (const Hash h, void(*func)(MemPool, void *))
 
void hend (const Hash h)
 
 __attribute__ ((hot, pure))
 

Function Documentation

◆ __attribute__()

__attribute__ ( (hot, pure) )

Definition at line 20 of file hash.c.

20 {
21 unsigned int h = 0;
22 const unsigned char *s;
23 for (s = (unsigned char *)s0; *s; ++s) h = h * 65599 + *s;
24 return h;
25}

◆ hdel()

void hdel ( const Hash h,
void(*)(MemPool, void *) func )

Definition at line 8 of file hash.c.

8 {
9 for (unsigned int i = h->size + 1; --i;) {
10 void *s = h->table[i - 1];
11 if (s) {
12 func(h->p, s);
13 h->table[i - 1] = NULL;
14 }
15 }
16}
void ** table
Definition hash.h:8
MemPool p
Definition hash.h:10
size_t size
Definition hash.h:9

◆ hend()

void hend ( const Hash h)

Definition at line 18 of file hash.c.

18{ xfree(h->table); }
#define xfree(a)
Definition xalloc.h:28

◆ hini()

void hini ( Hash h,
const uint nmemb )

Definition at line 3 of file hash.c.

3 {
4 h->table = (void *)xcalloc(((nmemb + 3) & 0xfffffffc), sizeof(void *));
5 h->size = nmemb;
6}
static ANEW void * xcalloc(const m_uint n, const m_uint sz)
Definition xalloc.h:18