summaryrefslogtreecommitdiff
path: root/src/hos_hash.cpp
diff options
context:
space:
mode:
author彭宣正 <[email protected]>2021-07-12 11:09:53 +0800
committer彭宣正 <[email protected]>2021-08-06 15:19:29 +0800
commit5c7d01b264bee89769536b5f657a4ea91ba41252 (patch)
tree78fa550ad977fa09be9764b5476f6d7328d4bc5a /src/hos_hash.cpp
parenta3cbaeb0cc0af74b909aa317882fdfc04592e5ef (diff)
✨ feat(src): refactorfeature-refactor
Diffstat (limited to 'src/hos_hash.cpp')
-rw-r--r--src/hos_hash.cpp97
1 files changed, 0 insertions, 97 deletions
diff --git a/src/hos_hash.cpp b/src/hos_hash.cpp
deleted file mode 100644
index bb7e2538..00000000
--- a/src/hos_hash.cpp
+++ /dev/null
@@ -1,97 +0,0 @@
-/*************************************************************************
- > File Name: uthash.cpp
- > Author: pxz
- > Created Time: Fri 18 Sep 2020 04:26:09 PM CST
- ************************************************************************/
-#include "hos_hash.h"
-
-void add_fd_context(hos_fd_context_t **handle, hos_fd_context_t *input)
-{
- hos_fd_context_t *value = NULL;
- HASH_FIND_INT(*handle, (int *)&input->fd, value);
- if (value == NULL)
- {
- value = (hos_fd_context_t *)malloc(sizeof(hos_fd_context_t));
- memcpy(value, input, sizeof(hos_fd_context_t));
- value->object = (char *)calloc(1, strlen(input->object) + 1);
- value->bucket = (char *)calloc(1, strlen(input->bucket) + 1);
- memcpy(value->bucket, input->bucket, strlen(input->bucket));
- memcpy(value->object, input->object, strlen(input->object));
- HASH_ADD_INT(*handle, fd, value);
- }
- else
- {
- value->mode = input->mode;
- if (value->object != NULL)
- {
- free(value->object);
- value->object = NULL;
- }
- if (value->bucket != NULL)
- {
- free(value->bucket);
- value->bucket = NULL;
- }
- value->object = (char *)calloc(1, strlen(input->object) + 1);
- value->bucket = (char *)calloc(1, strlen(input->bucket) + 1);
- memcpy(value->bucket, input->bucket, strlen(input->bucket));
- memcpy(value->object, input->object, strlen(input->object));
- value->callback = input->callback;
- value->userdata = input->userdata;
- value->cache = input->cache;
- value->cache_count = input->cache_count;
- value->cache_rest = input->cache_rest;
- value->position = input->position;
- value->recive_cnt = input->recive_cnt;
- value->fd_status = value->fd_status;
- }
-}
-
-hos_fd_context_t *find_context_by_fd(hos_fd_context_t *handle, size_t fd)
-{
- hos_fd_context_t *value = NULL;
- HASH_FIND_INT(handle, &fd, value);
- return value;
-}
-
-void delete_context_by_fd(hos_fd_context_t **handle, size_t fd)
-{
- hos_fd_context_t *value = NULL;
-
- HASH_FIND_INT(*handle, &fd, value);
- if (value)
- {
- if (value->bucket)
- {
- free(value->bucket);
- value->bucket = NULL;
- }
- if (value->object)
- {
- free(value->object);
- value->object = NULL;
- }
- HASH_DEL(*handle, value);
- free(value);
- }
-}
-
-void delete_all(hos_fd_context_t **handle)
-{
- hos_fd_context_t *current, *tmp;
- HASH_ITER(hh, *handle, current, tmp)
- {
- if (current->bucket)
- {
- free(current->bucket);
- current->bucket = NULL;
- }
- if (current->object)
- {
- free(current->object);
- current->object = NULL;
- }
- HASH_DEL(*handle, current);
- free(current);
- }
-}