suricata
util-pool.h
Go to the documentation of this file.
1
/* Copyright (C) 2007-2010 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
* \ingroup utilpool
20
*
21
* @{
22
*/
23
24
/**
25
* \file
26
*
27
* \author Victor Julien <victor@inliniac.net>
28
*/
29
30
#ifndef SURICATA_UTIL_POOL_H
31
#define SURICATA_UTIL_POOL_H
32
33
#define POOL_BUCKET_PREALLOCATED (1 << 0)
34
35
/* pool bucket structure */
36
typedef
struct
PoolBucket_
{
37
void
*
data
;
38
uint8_t
flags
;
39
struct
PoolBucket_
*
next
;
40
}
PoolBucket
;
41
42
/* pool structure */
43
typedef
struct
Pool_
{
44
uint32_t
max_buckets
;
45
uint32_t
preallocated
;
46
uint32_t
allocated
;
/**< counter of data elements, both currently in
47
* the pool and outside of it (outstanding) */
48
49
uint32_t
alloc_stack_size
;
50
51
PoolBucket
*
alloc_stack
;
52
53
PoolBucket
*
empty_stack
;
54
uint32_t
empty_stack_size
;
55
56
int
data_buffer_size
;
57
void
*
data_buffer
;
58
PoolBucket
*
pb_buffer
;
59
60
void
*(*Alloc)(void);
61
int (*
Init
)(
void
*,
void
*);
62
void
*
InitData
;
63
void (*
Cleanup
)(
void
*);
64
void (*
Free
)(
void
*);
65
66
uint32_t
elt_size
;
67
uint32_t
outstanding
;
/**< counter of data items 'in use'. Pretty much
68
* the diff between PoolGet and PoolReturn */
69
#ifdef DEBUG
70
uint32_t max_outstanding;
/**< max value of outstanding we saw */
71
#endif
72
}
Pool
;
73
74
/* prototypes */
75
Pool
*
PoolInit
(uint32_t, uint32_t, uint32_t,
void
*(*Alloc)(
void
),
int
(*Init)(
void
*,
void
*),
void
*,
void
(*Cleanup)(
void
*),
void
(*Free)(
void
*));
76
void
PoolFree
(
Pool
*);
77
78
void
*
PoolGet
(
Pool
*);
79
void
PoolReturn
(
Pool
*,
void
*);
80
81
void
PoolRegisterTests
(
void
);
82
83
#endif
/* SURICATA_UTIL_POOL_H */
84
85
/**
86
* @}
87
*/
Pool_::pb_buffer
PoolBucket * pb_buffer
Definition:
util-pool.h:58
Pool_::Free
void(* Free)(void *)
Definition:
util-pool.h:64
Pool_::Init
int(* Init)(void *, void *)
Definition:
util-pool.h:61
PoolRegisterTests
void PoolRegisterTests(void)
Definition:
util-pool.c:705
Pool_::alloc_stack
PoolBucket * alloc_stack
Definition:
util-pool.h:51
Pool_
Definition:
util-pool.h:43
Pool_::Cleanup
void(* Cleanup)(void *)
Definition:
util-pool.h:63
PoolBucket
struct PoolBucket_ PoolBucket
Pool_::empty_stack_size
uint32_t empty_stack_size
Definition:
util-pool.h:54
PoolBucket_::next
struct PoolBucket_ * next
Definition:
util-pool.h:39
Pool_::outstanding
uint32_t outstanding
Definition:
util-pool.h:67
PoolBucket_::data
void * data
Definition:
util-pool.h:37
PoolFree
void PoolFree(Pool *)
Definition:
util-pool.c:223
PoolBucket_
Definition:
util-pool.h:36
PoolReturn
void PoolReturn(Pool *, void *)
Definition:
util-pool.c:329
Pool_::max_buckets
uint32_t max_buckets
Definition:
util-pool.h:44
Pool_::preallocated
uint32_t preallocated
Definition:
util-pool.h:45
Pool_::allocated
uint32_t allocated
Definition:
util-pool.h:46
PoolGet
void * PoolGet(Pool *)
Definition:
util-pool.c:271
Pool_::data_buffer_size
int data_buffer_size
Definition:
util-pool.h:56
Pool_::empty_stack
PoolBucket * empty_stack
Definition:
util-pool.h:53
PoolBucket_::flags
uint8_t flags
Definition:
util-pool.h:38
Pool_::elt_size
uint32_t elt_size
Definition:
util-pool.h:66
PoolInit
Pool * PoolInit(uint32_t, uint32_t, uint32_t, void *(*Alloc)(void), int(*Init)(void *, void *), void *, void(*Cleanup)(void *), void(*Free)(void *))
Init a Pool.
Definition:
util-pool.c:84
Pool_::InitData
void * InitData
Definition:
util-pool.h:62
Pool_::alloc_stack_size
uint32_t alloc_stack_size
Definition:
util-pool.h:49
Pool_::data_buffer
void * data_buffer
Definition:
util-pool.h:57
Pool
struct Pool_ Pool
src
util-pool.h
Generated on Sat Dec 21 2024 23:30:38 for suricata by
1.8.18