mirror of
https://github.com/MidnightCommander/mc
synced 2024-12-23 04:46:55 +03:00
60f2d8d3c0
- isspace & toupper needs an unsigned char as arg - collision with compiler namespace __X - resolved some typos Signed-off-by: Patrick Winnertz <winnie@debian.org>
50 lines
956 B
C
50 lines
956 B
C
#ifndef MHL_STRHASH_H
|
|
#define MHL_STRHASH_H
|
|
|
|
#include <hash.h>
|
|
#include <mhl/memory.h>
|
|
|
|
static void __mhl_strhash_free_key(void* ptr)
|
|
{
|
|
mhl_mem_free(ptr);
|
|
}
|
|
|
|
static void __mhl_strhash_free_dummy(void* ptr)
|
|
{
|
|
}
|
|
|
|
typedef hash MHL_STRHASH;
|
|
|
|
#define MHL_STRHASH_DECLARE(n) MHL_STRHASH n;
|
|
|
|
#define MHL_STRHASH_INIT(h) \
|
|
hash_initialise(h, 997U, \
|
|
hash_hash_string, \
|
|
hash_compare_string, \
|
|
hash_copy_string, \
|
|
__mhl_strhash_free_key, \
|
|
__mhl_strhash_free_dummy)
|
|
|
|
#define MHL_STRHASH_DECLARE_INIT(n) \
|
|
MHL_STRHASH_DECLARE(n); \
|
|
MHL_STRHASH_INIT(&n);
|
|
|
|
#define MHL_STRHASH_DEINIT(ht) \
|
|
hash_deinitialise(ht)
|
|
|
|
static inline void mhl_strhash_addkey(MHL_STRHASH* ht, const char* key, void* value)
|
|
{
|
|
hash_insert(ht, (char*)key, value);
|
|
}
|
|
|
|
static inline void* mhl_strhash_lookup(MHL_STRHASH* ht, const char* key)
|
|
{
|
|
void* retptr;
|
|
if (hash_retrieve(ht, (char*)key, &retptr))
|
|
return retptr;
|
|
else
|
|
return NULL;
|
|
}
|
|
|
|
#endif
|