From fbae1053ae3003d01cca7bd02e1a9ee85ad44da7 Mon Sep 17 00:00:00 2001 From: YuQing <384681@qq.com> Date: Tue, 25 Apr 2023 09:26:50 +0800 Subject: [PATCH] fdht_client/fdht_func.c: fixed compile error --- storage/fdht_client/fdht_func.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/storage/fdht_client/fdht_func.c b/storage/fdht_client/fdht_func.c index 476e87f..922e4ae 100644 --- a/storage/fdht_client/fdht_func.c +++ b/storage/fdht_client/fdht_func.c @@ -225,8 +225,10 @@ int fdht_split_ids(const char *szIds, int **ppIds, int *id_count) } if (alloc_count < *id_count + (count + 1)) { + int *new_ids; + alloc_count += count + 1; - int *new_ids = (int *)realloc(*ppIds, \ + new_ids = (int *)realloc(*ppIds, sizeof(int) * alloc_count); if (new_ids == NULL) { @@ -237,7 +239,7 @@ int fdht_split_ids(const char *szIds, int **ppIds, int *id_count) __LINE__, \ (int)sizeof(int) * alloc_count,\ result, STRERROR(result)); - free(*ppIds) + free(*ppIds); *ppIds = NULL; break; } @@ -497,12 +499,14 @@ int fdht_load_groups_ex(IniContext *pIniContext, \ if (pGroupArray->server_count >= \ alloc_server_count) { - alloc_server_count = \ - pGroupArray->server_count + \ + FDHTServerInfo *new_servers; + + alloc_server_count = + pGroupArray->server_count + pGroupArray->group_count + 8; - FDHTServerInfo* new_servers = (FDHTServerInfo*) - realloc(pGroupArray->servers, \ - sizeof(FDHTServerInfo) * \ + new_servers = (FDHTServerInfo *) + realloc(pGroupArray->servers, + sizeof(FDHTServerInfo) * alloc_server_count); if (new_servers == NULL) { @@ -579,8 +583,8 @@ int fdht_load_groups_ex(IniContext *pIniContext, \ if (alloc_server_count > pGroupArray->server_count) { - FDHTServerInfo* new_servers= (FDHTServerInfo*)realloc( \ - pGroupArray->servers, sizeof(FDHTServerInfo) \ + FDHTServerInfo *new_servers= (FDHTServerInfo*)realloc( + pGroupArray->servers, sizeof(FDHTServerInfo) * pGroupArray->server_count); if (new_servers == NULL) {