Source
/*
** 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: create singly linked list (with custom memory functions) *
* *
* Parameters: queue - [IN] the list *
* mem_malloc_func - [IN] callback for malloc *
* mem_free_func - [IN] callback for free *
* *
******************************************************************************/
void zbx_list_create_ext(zbx_list_t *queue, zbx_mem_malloc_func_t mem_malloc_func, zbx_mem_free_func_t mem_free_func)
{
memset(queue, 0, sizeof(*queue));
queue->mem_malloc_func = mem_malloc_func;
queue->mem_free_func = mem_free_func;
}
/******************************************************************************
* *
* Purpose: create singly linked list *
* *
* Parameters: queue - [IN] the list *
* *
******************************************************************************/
void zbx_list_create(zbx_list_t *queue)
{
zbx_list_create_ext(queue, ZBX_DEFAULT_MEM_MALLOC_FUNC, ZBX_DEFAULT_MEM_FREE_FUNC);
}
/******************************************************************************
* *
* Purpose: destroy list *
* *
* Parameters: list - [IN] the list *
* *
******************************************************************************/
void zbx_list_destroy(zbx_list_t *list)
{
while (FAIL != zbx_list_pop(list, NULL))
;