Source
if (NULL != (pGNSI = (PGNSI)GetProcAddress(GetModuleHandle(TEXT("kernel32.dll")), "GetNativeSystemInfo")))
/*
** Zabbix
** Copyright (C) 2001-2023 Zabbix SIA
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation; either version 2 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**/
/******************************************************************************
* *
* Purpose: join strings into one, placing separator in between them, *
* skipping empty strings *
* *
* Parameters: separator - separator to place in between strings *
* count - number of strings *
* ... - strings to join (strings can be empty or NULL) *
* *
******************************************************************************/
static char *join_nonempty_strs(const char *separator, size_t count, ...)
{
char *arg;
va_list args;
char **nonempty_strs;
char *res = NULL;
size_t num_nonempty = 0, str_size = 0;
nonempty_strs = zbx_malloc(NULL, sizeof(char *) * count);
va_start(args, count);
for (size_t i = 0; i < count; i++)
{
arg = va_arg(args, char *);
if (NULL != arg && 0 < strlen(arg))
{
str_size += strlen(arg) + strlen(separator);
nonempty_strs[num_nonempty++] = arg;
}
}
va_end(args);
if (0 < num_nonempty)
{
res = zbx_malloc(NULL, str_size * sizeof(char));
res[0] = '\0';
strcat(res, nonempty_strs[0]);
for (size_t i = 1; i < num_nonempty; i++) {
strcat(res, separator);
strcat(res, nonempty_strs[i]);
}
}
zbx_free(nonempty_strs);
return res;
}