diff options
| author | “pengxuanzheng” <[email protected]> | 2021-09-24 10:44:30 +0800 |
|---|---|---|
| committer | pengxuanzheng <[email protected]> | 2021-09-24 15:43:47 +0800 |
| commit | f9bce9d590407cea1ab9764f7c10342ffb4eb795 (patch) | |
| tree | 2de3b0d69d0f61c2b3a80067cd472ce5bad8c5ad /src/hos_hash.cpp | |
| parent | 9250031fac8f5c5eec8c17498923315ea8a38a23 (diff) | |
🦄 refactor(TSG-7851): 重构fd,使用内存地址作为fdv2.0.5
Diffstat (limited to 'src/hos_hash.cpp')
| -rw-r--r-- | src/hos_hash.cpp | 97 |
1 files changed, 0 insertions, 97 deletions
diff --git a/src/hos_hash.cpp b/src/hos_hash.cpp deleted file mode 100644 index 22ff9954..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(hh,*handle,&input->fd,sizeof(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(hh,*handle,fd,sizeof(long),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(hh,handle,&fd,sizeof(long),value); - return value; -} - -void delete_context_by_fd(hos_fd_context_t **handle, size_t fd) -{ - hos_fd_context_t *value = NULL; - - HASH_FIND(hh,*handle,&fd,sizeof(long),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); - } -} |
