fdht_client/fdht_func.c: fixed compile error

pull/481/merge
YuQing 2023-04-25 09:26:50 +08:00
parent 5335a59313
commit fbae1053ae
1 changed files with 13 additions and 9 deletions

View File

@ -225,8 +225,10 @@ int fdht_split_ids(const char *szIds, int **ppIds, int *id_count)
} }
if (alloc_count < *id_count + (count + 1)) if (alloc_count < *id_count + (count + 1))
{ {
int *new_ids;
alloc_count += count + 1; alloc_count += count + 1;
int *new_ids = (int *)realloc(*ppIds, \ new_ids = (int *)realloc(*ppIds,
sizeof(int) * alloc_count); sizeof(int) * alloc_count);
if (new_ids == NULL) if (new_ids == NULL)
{ {
@ -237,7 +239,7 @@ int fdht_split_ids(const char *szIds, int **ppIds, int *id_count)
__LINE__, \ __LINE__, \
(int)sizeof(int) * alloc_count,\ (int)sizeof(int) * alloc_count,\
result, STRERROR(result)); result, STRERROR(result));
free(*ppIds) free(*ppIds);
*ppIds = NULL; *ppIds = NULL;
break; break;
} }
@ -497,12 +499,14 @@ int fdht_load_groups_ex(IniContext *pIniContext, \
if (pGroupArray->server_count >= \ if (pGroupArray->server_count >= \
alloc_server_count) alloc_server_count)
{ {
alloc_server_count = \ FDHTServerInfo *new_servers;
pGroupArray->server_count + \
alloc_server_count =
pGroupArray->server_count +
pGroupArray->group_count + 8; pGroupArray->group_count + 8;
FDHTServerInfo* new_servers = (FDHTServerInfo*) new_servers = (FDHTServerInfo *)
realloc(pGroupArray->servers, \ realloc(pGroupArray->servers,
sizeof(FDHTServerInfo) * \ sizeof(FDHTServerInfo) *
alloc_server_count); alloc_server_count);
if (new_servers == NULL) if (new_servers == NULL)
{ {
@ -579,8 +583,8 @@ int fdht_load_groups_ex(IniContext *pIniContext, \
if (alloc_server_count > pGroupArray->server_count) if (alloc_server_count > pGroupArray->server_count)
{ {
FDHTServerInfo* new_servers= (FDHTServerInfo*)realloc( \ FDHTServerInfo *new_servers= (FDHTServerInfo*)realloc(
pGroupArray->servers, sizeof(FDHTServerInfo) \ pGroupArray->servers, sizeof(FDHTServerInfo)
* pGroupArray->server_count); * pGroupArray->server_count);
if (new_servers == NULL) if (new_servers == NULL)
{ {