fix bug #608
This commit is contained in:
parent
c26f9ff6af
commit
24e40e8e64
|
@ -22,17 +22,17 @@ extern "C" {
|
|||
|
||||
#include <stdint.h>
|
||||
|
||||
void *taosInitIntHash(int32_t maxSessions, int32_t dataSize, int32_t (*fp)(void *, int32_t));
|
||||
void *taosInitIntHash(int32_t maxSessions, int32_t dataSize, int32_t (*fp)(void *, uint64_t));
|
||||
|
||||
void taosCleanUpIntHash(void *handle);
|
||||
|
||||
char *taosGetIntHashData(void *handle, int32_t key);
|
||||
char *taosGetIntHashData(void *handle, uint64_t key);
|
||||
|
||||
void taosDeleteIntHash(void *handle, int32_t key);
|
||||
void taosDeleteIntHash(void *handle, uint64_t key);
|
||||
|
||||
char *taosAddIntHash(void *handle, int32_t key, char *pData);
|
||||
char *taosAddIntHash(void *handle, uint64_t key, char *pData);
|
||||
|
||||
int32_t taosHashInt(void *handle, int32_t key);
|
||||
int32_t taosHashInt(void *handle, uint64_t key);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
#include "os.h"
|
||||
|
||||
typedef struct _str_node_t {
|
||||
int32_t key;
|
||||
uint64_t key;
|
||||
struct _str_node_t *prev;
|
||||
struct _str_node_t *next;
|
||||
char data[];
|
||||
|
@ -33,18 +33,18 @@ typedef struct {
|
|||
IHashNode **hashList;
|
||||
int32_t maxSessions;
|
||||
int32_t dataSize;
|
||||
int32_t (*hashFp)(void *, int32_t key);
|
||||
int32_t (*hashFp)(void *, uint64_t key);
|
||||
pthread_mutex_t mutex;
|
||||
} IHashObj;
|
||||
|
||||
int32_t taosHashInt(void *handle, int32_t key) {
|
||||
int32_t taosHashInt(void *handle, uint64_t key) {
|
||||
IHashObj *pObj = (IHashObj *)handle;
|
||||
int32_t hash = 0;
|
||||
hash = key % pObj->maxSessions;
|
||||
return hash;
|
||||
}
|
||||
|
||||
char *taosAddIntHash(void *handle, int32_t key, char *pData) {
|
||||
char *taosAddIntHash(void *handle, uint64_t key, char *pData) {
|
||||
int32_t hash;
|
||||
IHashNode *pNode;
|
||||
IHashObj * pObj;
|
||||
|
@ -75,7 +75,7 @@ char *taosAddIntHash(void *handle, int32_t key, char *pData) {
|
|||
return (char *)pNode->data;
|
||||
}
|
||||
|
||||
void taosDeleteIntHash(void *handle, int32_t key) {
|
||||
void taosDeleteIntHash(void *handle, uint64_t key) {
|
||||
int32_t hash;
|
||||
IHashNode *pNode;
|
||||
IHashObj * pObj;
|
||||
|
@ -111,7 +111,7 @@ void taosDeleteIntHash(void *handle, int32_t key) {
|
|||
pthread_mutex_unlock(&pObj->mutex);
|
||||
}
|
||||
|
||||
char *taosGetIntHashData(void *handle, int32_t key) {
|
||||
char *taosGetIntHashData(void *handle, uint64_t key) {
|
||||
int32_t hash;
|
||||
IHashNode *pNode;
|
||||
IHashObj * pObj;
|
||||
|
@ -140,7 +140,7 @@ char *taosGetIntHashData(void *handle, int32_t key) {
|
|||
return NULL;
|
||||
}
|
||||
|
||||
void *taosInitIntHash(int32_t maxSessions, int32_t dataSize, int32_t (*fp)(void *, int32_t)) {
|
||||
void *taosInitIntHash(int32_t maxSessions, int32_t dataSize, int32_t (*fp)(void *, uint64_t)) {
|
||||
IHashObj *pObj;
|
||||
|
||||
pObj = (IHashObj *)malloc(sizeof(IHashObj));
|
||||
|
|
Loading…
Reference in New Issue