From 82dc6b00e7632ccadf315030926c1eaa51ecb3fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BD=AD=E5=AE=A3=E6=AD=A3?= Date: Mon, 12 Apr 2021 16:56:05 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9Efix(hos=5Fset=5Fthread=5Fsum):=20?= =?UTF-8?q?=E5=88=9D=E5=A7=8B=E5=8C=96hash=5Fhos=5Finfo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/hos_client.cpp | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/hos_client.cpp b/src/hos_client.cpp index 76f635cc..9e56bf2e 100644 --- a/src/hos_client.cpp +++ b/src/hos_client.cpp @@ -195,7 +195,6 @@ void hos_set_cache_count(hos_client_handle client, size_t cache_count) void hos_set_thread_sum(hos_client_handle client, size_t thread_sum) { - void *tmp = NULL; if (client == NULL) { return; @@ -215,12 +214,8 @@ void hos_set_thread_sum(hos_client_handle client, size_t thread_sum) } if (hash_hos_info) { - tmp = malloc(client->thread_sum * sizeof(hos_info_t *)); - memcpy(tmp, hash_hos_info, client->thread_sum * sizeof(hos_info_t *)); hash_hos_info = (hos_info_t **)realloc(hash_hos_info, thread_sum * sizeof(hos_info_t *)); - memset(hash_hos_info, 0, thread_sum * sizeof(hos_info_t *)); - memcpy(hash_hos_info, tmp, thread_sum * sizeof(hos_info_t*)); - free(tmp); + memset(&hash_hos_info[client->thread_sum], 0, (thread_sum - client->thread_sum) * sizeof(hos_info_t *)); } else {