Source
void um_cache_resolve(const zbx_um_cache_t *cache, const zbx_uint64_t *hostids, int hostids_num, const char *macro,
/*
** 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/>.
**/
ZBX_PTR_VECTOR_IMPL(um_macro, zbx_um_macro_t *)
ZBX_PTR_VECTOR_IMPL(um_host, zbx_um_host_t *)
typedef enum
{
ZBX_UM_UPDATE_HOST,
ZBX_UM_UPDATE_MACRO
}
zbx_um_update_cause_t;
/*********************************************************************************
* *
* Purpose: create duplicate user macro cache *
* *
* Parameters: cache - [IN] the user macro cache to duplicate *
* *
* Return value: The duplicated user macro cache. *
* *
* Comments: The internal structures are duplicated copying references of *
* cached objects and incrementing their reference counters. *
* *
*********************************************************************************/
static zbx_um_cache_t *um_cache_dup(zbx_um_cache_t *cache)
{
zbx_um_cache_t *dup;
zbx_um_host_t **phost;
zbx_hashset_iter_t iter;
dup = (zbx_um_cache_t *)dbconfig_shmem_malloc_func(NULL, sizeof(zbx_um_cache_t));
dup->refcount = 1;
zbx_hashset_copy(&dup->hosts, &cache->hosts, sizeof(zbx_um_host_t *));
zbx_hashset_iter_reset(&dup->hosts, &iter);
while (NULL != (phost = (zbx_um_host_t **)zbx_hashset_iter_next(&iter)))
(*phost)->refcount++;