1 /*
2 ** Zabbix
3 ** Copyright (C) 2001-2021 Zabbix SIA
4 **
5 ** This program is free software; you can redistribute it and/or modify
6 ** it under the terms of the GNU General Public License as published by
7 ** the Free Software Foundation; either version 2 of the License, or
8 ** (at your option) any later version.
9 **
10 ** This program is distributed in the hope that it will be useful,
11 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
12 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 ** GNU General Public License for more details.
14 **
15 ** You should have received a copy of the GNU General Public License
16 ** along with this program; if not, write to the Free Software
17 ** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
18 **/
19 
20 #include "lld.h"
21 
22 /******************************************************************************
23  *                                                                            *
24  * Function: lld_field_str_rollback                                           *
25  *                                                                            *
26  * Author: Alexander Vladishev                                                *
27  *                                                                            *
28  ******************************************************************************/
lld_field_str_rollback(char ** field,char ** field_orig,zbx_uint64_t * flags,zbx_uint64_t flag)29 void	lld_field_str_rollback(char **field, char **field_orig, zbx_uint64_t *flags, zbx_uint64_t flag)
30 {
31 	if (0 == (*flags & flag))
32 		return;
33 
34 	zbx_free(*field);
35 	*field = *field_orig;
36 	*field_orig = NULL;
37 	*flags &= ~flag;
38 }
39 
40 /******************************************************************************
41  *                                                                            *
42  * Function: lld_field_uint64_rollback                                        *
43  *                                                                            *
44  * Author: Alexander Vladishev                                                *
45  *                                                                            *
46  ******************************************************************************/
lld_field_uint64_rollback(zbx_uint64_t * field,zbx_uint64_t * field_orig,zbx_uint64_t * flags,zbx_uint64_t flag)47 void	lld_field_uint64_rollback(zbx_uint64_t *field, zbx_uint64_t *field_orig, zbx_uint64_t *flags, zbx_uint64_t flag)
48 {
49 	if (0 == (*flags & flag))
50 		return;
51 
52 	*field = *field_orig;
53 	*field_orig = 0;
54 	*flags &= ~flag;
55 }
56