Source
if (NULL == (entry = (ZBX_HASHSET_ENTRY_T *)hs->mem_malloc_func(NULL, ZBX_HASHSET_ENTRY_OFFSET + size)))
/*
** Copyright (C) 2001-2025 Zabbix SIA
**
** This program is free software: you can redistribute it and/or modify it under the terms of
** the GNU Affero General Public License as published by the Free Software Foundation, version 3.
**
** 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 Affero General Public License for more details.
**
** You should have received a copy of the GNU Affero General Public License along with this program.
** If not, see <https://www.gnu.org/licenses/>.
**/
static void __hashset_free_entry(zbx_hashset_t *hs, ZBX_HASHSET_ENTRY_T *entry);
/* private hashset functions */
static void __hashset_free_entry(zbx_hashset_t *hs, ZBX_HASHSET_ENTRY_T *entry)
{
if (NULL != hs->clean_func)
hs->clean_func(entry->data);
hs->mem_free_func(entry);
}
static int zbx_hashset_init_slots(zbx_hashset_t *hs, size_t init_size)
{
hs->num_data = 0;
if (0 < init_size)
{
hs->num_slots = next_prime(init_size);
if (NULL == (hs->slots = (ZBX_HASHSET_ENTRY_T **)hs->mem_malloc_func(NULL, hs->num_slots *
sizeof(ZBX_HASHSET_ENTRY_T *))))
{
return FAIL;
}
memset(hs->slots, 0, hs->num_slots * sizeof(ZBX_HASHSET_ENTRY_T *));
}
else
{
hs->num_slots = 0;
hs->slots = NULL;
}
return SUCCEED;
}
/* public hashset interface */
void zbx_hashset_create(zbx_hashset_t *hs, size_t init_size,
zbx_hash_func_t hash_func,