1
1

inserting string values into hash table is broken

This commit was SVN r544.
Этот коммит содержится в:
Tim Woodall 2004-01-26 16:51:06 +00:00
родитель 767d71aa86
Коммит 33e9e8417a
2 изменённых файлов: 33 добавлений и 7 удалений

Просмотреть файл

@ -23,7 +23,7 @@ lam_class_info_t lam_fast_hash_cls = {
*/ */
#define MULTIPLIER 31 #define MULTIPLIER 31
static inline uint32_t lam_hash_value(const char * key, uint32_t keysize) static inline uint32_t lam_hash_value(const unsigned char * key, uint32_t keysize)
{ {
uint32_t h, i; uint32_t h, i;
const char *p; const char *p;
@ -235,6 +235,23 @@ int lam_fh_set_value_for_ikey(lam_fast_hash_t *htbl, void *val, uint32_t key)
} }
void *lam_fh_get_value_for_lkey(lam_fast_hash_t *htbl, uint64_t key)
{
return lam_fh_get_value(htbl, &key, sizeof(key));
}
void lam_fh_remove_value_for_lkey(lam_fast_hash_t *htbl, uint64_t key)
{
lam_fh_remove_value(htbl, &key, sizeof(key));
}
int lam_fh_set_value_for_lkey(lam_fast_hash_t *htbl, void *val, uint64_t key)
{
return lam_fh_set_value(htbl, val, &key, sizeof(key));
}
void *lam_fh_get_value_for_skey(lam_fast_hash_t *htbl, const char *key) void *lam_fh_get_value_for_skey(lam_fast_hash_t *htbl, const char *key)
{ {

Просмотреть файл

@ -7,14 +7,12 @@
#include "lam_config.h" #include "lam_config.h"
#include "lam/stdint.h" #include "lam/stdint.h"
#include "lam/types.h"
#include "lam/lfc/object.h" #include "lam/lfc/object.h"
typedef struct lam_fhnode typedef struct lam_fhnode
{ {
union{ lam_ptr_t fhn_key;
uint32_t ikey;
char *skey;
} fhn_key;
void *fhn_value; void *fhn_value;
char fhn_is_taken; /* 1->node is occupied, 0-> not occupied */ char fhn_is_taken; /* 1->node is occupied, 0-> not occupied */
} lam_fhnode_t; } lam_fhnode_t;
@ -48,10 +46,21 @@ void *lam_fh_get_value_for_ikey(lam_fast_hash_t *htbl, uint32_t key);
void lam_fh_remove_value_for_ikey(lam_fast_hash_t *htbl, uint32_t key); void lam_fh_remove_value_for_ikey(lam_fast_hash_t *htbl, uint32_t key);
int lam_fh_set_value_for_ikey(lam_fast_hash_t *htbl, void *val, uint32_t key); int lam_fh_set_value_for_ikey(lam_fast_hash_t *htbl, void *val, uint32_t key);
void *lam_fh_get_value_for_lkey(lam_fast_hash_t *htbl, uint64_t key);
void lam_fh_remove_value_for_lkey(lam_fast_hash_t *htbl, uint64_t key);
int lam_fh_set_value_for_lkey(lam_fast_hash_t *htbl, void *val, uint64_t key);
#if 0
/*
* TSW - This is broken - implementation tried to copy length of string
* into space allocated for a pointer
*/
void *lam_fh_get_value_for_skey(lam_fast_hash_t *htbl, const char *key); void *lam_fh_get_value_for_skey(lam_fast_hash_t *htbl, const char *key);
void lam_fh_remove_value_for_skey(lam_fast_hash_t *htbl, const char *key); void lam_fh_remove_value_for_skey(lam_fast_hash_t *htbl, const char *key);
int lam_fh_set_value_for_skey(lam_fast_hash_t *htbl, void *val, const char *key); int lam_fh_set_value_for_skey(lam_fast_hash_t *htbl, void *val, const char *key);
#endif
/* returns the number of items in the table */ /* returns the number of items in the table */
static uint32_t lam_fh_count(lam_fast_hash_t *htbl); static uint32_t lam_fh_count(lam_fast_hash_t *htbl);