summaryrefslogtreecommitdiff
path: root/src/hos_hash.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/hos_hash.cpp')
-rw-r--r--src/hos_hash.cpp30
1 files changed, 28 insertions, 2 deletions
diff --git a/src/hos_hash.cpp b/src/hos_hash.cpp
index f6bc8838..c10e9494 100644
--- a/src/hos_hash.cpp
+++ b/src/hos_hash.cpp
@@ -13,20 +13,28 @@ void add_hos_info(hos_info_t **handle, hos_info_t *input)
{
value = (hos_info_t *)malloc(sizeof(hos_info_t));
memcpy(value, input, sizeof(hos_info_t));
+ value->object = (char *)malloc(strlen(input->object) + 1);
+ value->bucket = (char *)malloc(strlen(input->bucket) + 1);
+ memcpy(value->bucket, input->bucket, strlen(input->bucket) + 1);
+ memcpy(value->object, input->object, strlen(input->object) + 1);
HASH_ADD_INT(*handle, fd, value);
}
else
{
value->mode = input->mode;
value->handle = input->handle;
- value->bucket = input->bucket;
- value->object = input->object;
+ memcpy(value->bucket, input->bucket, strlen(input->bucket) + 1);
+ memcpy(value->object, input->object, strlen(input->object) + 1);
value->callback = input->callback;
value->userdata = input->userdata;
value->cache = input->cache;
value->cache_times = input->cache_times;
value->cache_rest = input->cache_rest;
value->position = input->position;
+ value->recive_cnt = input->recive_cnt;
+ value->fd_status = value->fd_status;
+ value->overtime = value->overtime;
+ value->timeout = value->timeout;
}
}
@@ -40,9 +48,18 @@ hos_info_t *find_info_by_fd(hos_info_t *handle, size_t fd)
void delete_info_by_fd(hos_info_t **handle, size_t fd)
{
hos_info_t *value = NULL;
+
HASH_FIND_INT(*handle, &fd, value);
if (value)
{
+ if (value->bucket)
+ {
+ free(value->bucket);
+ }
+ if (value->object)
+ {
+ free(value->object);
+ }
HASH_DEL(*handle, value);
free(value);
}
@@ -53,6 +70,15 @@ void delete_all(hos_info_t **handle)
hos_info_t *current, *tmp;
HASH_ITER(hh, *handle, current, tmp)
{
+ if (current->bucket)
+ {
+ free(current->bucket);
+ }
+ if (current->object)
+ {
+ free(current->object);
+ }
HASH_DEL(*handle, current);
+ free(current);
}
}