提交 24e40e8e 编写于 作者: H hjxilinx

fix bug #608

上级 c26f9ff6
...@@ -22,17 +22,17 @@ extern "C" { ...@@ -22,17 +22,17 @@ extern "C" {
#include <stdint.h> #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); 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 #ifdef __cplusplus
} }
......
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
#include "os.h" #include "os.h"
typedef struct _str_node_t { typedef struct _str_node_t {
int32_t key; uint64_t key;
struct _str_node_t *prev; struct _str_node_t *prev;
struct _str_node_t *next; struct _str_node_t *next;
char data[]; char data[];
...@@ -33,18 +33,18 @@ typedef struct { ...@@ -33,18 +33,18 @@ typedef struct {
IHashNode **hashList; IHashNode **hashList;
int32_t maxSessions; int32_t maxSessions;
int32_t dataSize; int32_t dataSize;
int32_t (*hashFp)(void *, int32_t key); int32_t (*hashFp)(void *, uint64_t key);
pthread_mutex_t mutex; pthread_mutex_t mutex;
} IHashObj; } IHashObj;
int32_t taosHashInt(void *handle, int32_t key) { int32_t taosHashInt(void *handle, uint64_t key) {
IHashObj *pObj = (IHashObj *)handle; IHashObj *pObj = (IHashObj *)handle;
int32_t hash = 0; int32_t hash = 0;
hash = key % pObj->maxSessions; hash = key % pObj->maxSessions;
return hash; return hash;
} }
char *taosAddIntHash(void *handle, int32_t key, char *pData) { char *taosAddIntHash(void *handle, uint64_t key, char *pData) {
int32_t hash; int32_t hash;
IHashNode *pNode; IHashNode *pNode;
IHashObj * pObj; IHashObj * pObj;
...@@ -75,7 +75,7 @@ char *taosAddIntHash(void *handle, int32_t key, char *pData) { ...@@ -75,7 +75,7 @@ char *taosAddIntHash(void *handle, int32_t key, char *pData) {
return (char *)pNode->data; return (char *)pNode->data;
} }
void taosDeleteIntHash(void *handle, int32_t key) { void taosDeleteIntHash(void *handle, uint64_t key) {
int32_t hash; int32_t hash;
IHashNode *pNode; IHashNode *pNode;
IHashObj * pObj; IHashObj * pObj;
...@@ -111,7 +111,7 @@ void taosDeleteIntHash(void *handle, int32_t key) { ...@@ -111,7 +111,7 @@ void taosDeleteIntHash(void *handle, int32_t key) {
pthread_mutex_unlock(&pObj->mutex); pthread_mutex_unlock(&pObj->mutex);
} }
char *taosGetIntHashData(void *handle, int32_t key) { char *taosGetIntHashData(void *handle, uint64_t key) {
int32_t hash; int32_t hash;
IHashNode *pNode; IHashNode *pNode;
IHashObj * pObj; IHashObj * pObj;
...@@ -140,7 +140,7 @@ char *taosGetIntHashData(void *handle, int32_t key) { ...@@ -140,7 +140,7 @@ char *taosGetIntHashData(void *handle, int32_t key) {
return NULL; 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; IHashObj *pObj;
pObj = (IHashObj *)malloc(sizeof(IHashObj)); pObj = (IHashObj *)malloc(sizeof(IHashObj));
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册