Source
void zbx_dbconn_prepare_vinsert(zbx_dbconn_t *db, zbx_db_insert_t *db_insert, const char *table, va_list args)
/*
** 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/>.
**/
/******************************************************************************
* *
* Purpose: releases resources allocated by bulk insert operations *
* *
* Parameters: self - [IN] the bulk insert data *
* *
******************************************************************************/
static void db_insert_clear_rows(zbx_db_insert_t *db_insert)
{
for (int i = 0; i < db_insert->rows.values_num; i++)
{
zbx_db_value_t *row = db_insert->rows.values[i];
for (int j = 0; j < db_insert->fields.values_num; j++)
{
const zbx_db_field_t *field = db_insert->fields.values[j];
switch (field->type)
{
case ZBX_TYPE_CHAR:
case ZBX_TYPE_TEXT:
case ZBX_TYPE_LONGTEXT:
case ZBX_TYPE_CUID:
case ZBX_TYPE_BLOB:
zbx_free(row[j].str);
break;
}
}
zbx_free(row);
}
zbx_vector_db_value_ptr_clear(&db_insert->rows);
}
/******************************************************************************
* *
* Purpose: release resources allocated by bulk insert operations *
* *
* Parameters: db_insert - [IN] the bulk insert data *