suricata
threadvars.c
Go to the documentation of this file.
1 /* Copyright (C) 2026 Open Information Security Foundation
2  *
3  * You can copy, redistribute or modify this Program under the terms of
4  * the GNU General Public License version 2 as published by the Free
5  * Software Foundation.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * version 2 along with this program; if not, write to the Free Software
14  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
15  * 02110-1301, USA.
16  */
17 
18 #include "suricata-common.h"
19 #include "threadvars.h"
20 #include "thread-storage.h"
21 
22 /**
23  * \brief Allocate a new ThreadVars structure.
24  *
25  * \retval NULL if allocation failed.
26  * \retval Pointer to newly allocated ThreadVars structure.
27  */
29 {
31  if (tv == NULL)
32  return NULL;
33  SC_ATOMIC_INIT(tv->flags);
34  return tv;
35 }
36 
37 /**
38  * \brief Free a ThreadVars structure.
39  *
40  * \param tv Pointer to ThreadVars structure to be freed.
41  */
43 {
44  if (tv == NULL)
45  return;
46  SCFree(tv);
47 }
SC_ATOMIC_INIT
#define SC_ATOMIC_INIT(name)
wrapper for initializing an atomic variable.
Definition: util-atomic.h:314
ThreadVarsAlloc
ThreadVars * ThreadVarsAlloc(void)
Allocate a new ThreadVars structure.
Definition: threadvars.c:28
ThreadVars_
Per thread variable structure.
Definition: threadvars.h:58
SCThreadStorageSize
unsigned int SCThreadStorageSize(void)
Definition: thread-storage.c:25
thread-storage.h
suricata-common.h
tv
ThreadVars * tv
Definition: fuzz_decodepcapfile.c:33
threadvars.h
SCFree
#define SCFree(p)
Definition: util-mem.h:61
ThreadVarsFree
void ThreadVarsFree(ThreadVars *tv)
Free a ThreadVars structure.
Definition: threadvars.c:42
SCCalloc
#define SCCalloc(nm, sz)
Definition: util-mem.h:53