Coverage Report

Created: 2026-09-06 07:25

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/suricata8/src/thread-callbacks.c
Line
Count
Source
1
/* Copyright (C) 2024 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 "thread-callbacks.h"
19
20
typedef struct ThreadInitCallback_ {
21
    SCThreadInitCallbackFn Callback;
22
    void *user;
23
    struct ThreadInitCallback_ *next;
24
} ThreadInitCallback;
25
26
static ThreadInitCallback *init_callbacks = NULL;
27
28
bool SCThreadRegisterInitCallback(SCThreadInitCallbackFn fn, void *user)
29
0
{
30
0
    ThreadInitCallback *cb = SCCalloc(1, sizeof(*cb));
31
0
    if (cb == NULL) {
32
0
        return false;
33
0
    }
34
0
    cb->Callback = fn;
35
0
    cb->user = user;
36
0
    if (init_callbacks == NULL) {
37
0
        init_callbacks = cb;
38
0
    } else {
39
0
        ThreadInitCallback *current = init_callbacks;
40
0
        while (current->next != NULL) {
41
0
            current = current->next;
42
0
        }
43
0
        current->next = cb;
44
0
    }
45
0
    return true;
46
0
}
47
48
void SCThreadRunInitCallbacks(ThreadVars *tv)
49
2
{
50
2
    ThreadInitCallback *cb = init_callbacks;
51
2
    while (cb != NULL) {
52
0
        cb->Callback(tv, cb->user);
53
0
        cb = cb->next;
54
0
    }
55
2
}