• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

OISF / suricata / 23374838686

21 Mar 2026 07:29AM UTC coverage: 59.341% (-20.0%) from 79.315%
23374838686

Pull #15075

github

web-flow
Merge 90b4e834f into 6587e363a
Pull Request #15075: Stack 8001 v16.4

38 of 70 new or added lines in 10 files covered. (54.29%)

34165 existing lines in 563 files now uncovered.

119621 of 201584 relevant lines covered (59.34%)

650666.92 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

52.63
/src/util-mpm-ac-queue.h
1
/* Copyright (C) 2025 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
/**
19
 * \file
20
 *
21
 * \author Anoop Saldanha <anoopsaldanha@gmail.com>
22
 *
23
 */
24

25
#ifndef SURICATA_UTIL_MPM_AC_QUEUE_H
26
#define SURICATA_UTIL_MPM_AC_QUEUE_H
27

28
#define STATE_QUEUE_CONTAINER_SIZE 65536
145,720✔
29

30
/**
31
 * \brief Helper structure used by AC during state table creation
32
 */
33
typedef struct StateQueue_ {
34
    uint32_t top;
35
    uint32_t bot;
36
    uint32_t size;
37
    int32_t *store;
38
} StateQueue;
39

40
StateQueue *SCACStateQueueAlloc(void);
41
void SCACStateQueueFree(StateQueue *q);
42

43
static inline int SCACStateQueueIsEmpty(StateQueue *q)
44
{
2,195,516✔
45
    if (q->top == q->bot)
2,195,516✔
46
        return 1;
145,720✔
47
    else
2,049,796✔
48
        return 0;
2,049,796✔
49
}
2,195,516✔
50

51
static inline void SCACEnqueue(StateQueue *q, int32_t state)
52
{
2,049,796✔
53
    /*if we already have this */
54
    for (uint32_t i = q->bot; i < q->top; i++) {
2,858,962✔
55
        if (q->store[i] == state)
809,166✔
56
            return;
×
57
    }
809,166✔
58

59
    q->store[q->top++] = state;
2,049,796✔
60

61
    if (q->top == q->size)
2,049,796✔
UNCOV
62
        q->top = 0;
×
63

64
    if (q->top == q->bot) {
2,049,796✔
65
        // allocate a new store and copy + realign
66
        int32_t *tmp = SCCalloc(q->size + STATE_QUEUE_CONTAINER_SIZE, sizeof(int32_t));
×
67
        if (tmp == NULL) {
×
68
            FatalError("Error reallocating memory");
×
69
        }
×
70
        memcpy(tmp, q->store + q->bot, (q->size - q->bot) * sizeof(int32_t));
×
71
        memcpy(tmp + (q->size - q->bot), q->store, q->top * sizeof(int32_t));
×
72
        SCFree(q->store);
×
73
        q->store = tmp;
×
74
        q->bot = 0;
×
75
        q->top = q->size;
×
76
        q->size += STATE_QUEUE_CONTAINER_SIZE;
×
77
    }
×
78
}
2,049,796✔
79

80
static inline int32_t SCACDequeue(StateQueue *q)
81
{
2,049,796✔
82
    if (q->bot == q->size)
2,049,796✔
UNCOV
83
        q->bot = 0;
×
84

85
    if (q->bot == q->top) {
2,049,796✔
86
        FatalError("StateQueue behaving weirdly.  "
×
87
                   "Fatal Error.  Exiting.  Please file a bug report on this");
×
88
    }
×
89

90
    return q->store[q->bot++];
2,049,796✔
91
}
2,049,796✔
92

93
#endif /* SURICATA_UTIL_MPM_AC_QUEUE_H */
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc