FFmpeg
|
#include <stdint.h>
#include <string.h>
#include "libavutil/attributes.h"
#include "libavutil/crc.h"
#include "libavutil/error.h"
#include "libavutil/macros.h"
#include "libavutil/mem.h"
#include "hashtable.h"
Go to the source code of this file.
Data Structures | |
struct | FFHashtableContext |
Macros | |
#define | ALIGN _Alignof(size_t) |
#define | ENTRY_PSL_VAL(entry) (*(size_t*)(entry)) |
#define | ENTRY_KEY_PTR(entry) ((entry) + sizeof(size_t)) |
#define | ENTRY_VAL_PTR(entry) (ENTRY_KEY_PTR(entry) + ctx->key_size) |
#define | KEYS_EQUAL(k1, k2) (!memcmp((k1), (k2), ctx->key_size)) |
Functions | |
av_cold int | ff_hashtable_alloc (FFHashtableContext **ctx, size_t key_size, size_t val_size, size_t max_entries) |
Create a fixed-sized Robin Hood hash table. More... | |
static size_t | hash_key (const struct FFHashtableContext *ctx, const void *key) |
int | ff_hashtable_get (const struct FFHashtableContext *ctx, const void *key, void *val) |
Look up a value from a hash table given a key. More... | |
int | ff_hashtable_set (struct FFHashtableContext *ctx, const void *key, const void *val) |
Store a value in a hash table given a key. More... | |
int | ff_hashtable_delete (struct FFHashtableContext *ctx, const void *key) |
Delete a value from a hash table given a key. More... | |
void | ff_hashtable_clear (struct FFHashtableContext *ctx) |
Delete all values from a hash table. More... | |
av_cold void | ff_hashtable_freep (FFHashtableContext **ctx) |
Free a hash table. More... | |
#define ALIGN _Alignof(size_t) |
Definition at line 32 of file hashtable.c.
Definition at line 53 of file hashtable.c.
Definition at line 54 of file hashtable.c.
#define ENTRY_VAL_PTR | ( | entry | ) | (ENTRY_KEY_PTR(entry) + ctx->key_size) |
Definition at line 55 of file hashtable.c.
#define KEYS_EQUAL | ( | k1, | |
k2 | |||
) | (!memcmp((k1), (k2), ctx->key_size)) |
Definition at line 57 of file hashtable.c.
av_cold int ff_hashtable_alloc | ( | struct FFHashtableContext ** | ctx, |
size_t | key_size, | ||
size_t | val_size, | ||
size_t | max_entries | ||
) |
Create a fixed-sized Robin Hood hash table.
ctx | context to allocate and initialize |
key_size | size of key type in bytes |
val_size | size of value type in bytes |
max_entries | maximum number of key-value pairs to store |
Definition at line 59 of file hashtable.c.
Referenced by dxv_init(), and main().
|
static |
Definition at line 92 of file hashtable.c.
Referenced by ff_hashtable_delete(), ff_hashtable_get(), and ff_hashtable_set().
int ff_hashtable_get | ( | const struct FFHashtableContext * | ctx, |
const void * | key, | ||
void * | val | ||
) |
Look up a value from a hash table given a key.
ctx | hash table context |
key | pointer to key data |
val | destination pointer for value data |
Definition at line 97 of file hashtable.c.
Referenced by dxv_compress_dxt1(), and main().
int ff_hashtable_set | ( | struct FFHashtableContext * | ctx, |
const void * | key, | ||
const void * | val | ||
) |
Store a value in a hash table given a key.
ctx | hash table context |
key | pointer to key data |
val | pointer for value data |
Definition at line 119 of file hashtable.c.
Referenced by dxv_compress_dxt1(), and main().
int ff_hashtable_delete | ( | struct FFHashtableContext * | ctx, |
const void * | key | ||
) |
Delete a value from a hash table given a key.
ctx | hash table context |
key | pointer to key data |
Definition at line 163 of file hashtable.c.
Referenced by dxv_compress_dxt1(), and main().
void ff_hashtable_clear | ( | struct FFHashtableContext * | ctx | ) |
Delete all values from a hash table.
ctx | hash table context |
Definition at line 201 of file hashtable.c.
Referenced by dxv_compress_dxt1().
av_cold void ff_hashtable_freep | ( | struct FFHashtableContext ** | ctx | ) |
Free a hash table.
ctx | hash table context |
Definition at line 206 of file hashtable.c.
Referenced by dxv_close(), ff_hashtable_alloc(), and main().