Line data Source code
1 : /* SPDX-FileCopyrightText: Copyright 2026 Cozens Software Solutions Limited
2 : * SPDX-License-Identifier: PolyForm-Noncommercial-1.0.0 OR LicenseRef-PolyForm-Internal-Use-1.0.0 OR LicenseRef-COSOSO-Commercial
3 : */
4 :
5 : #ifndef SOLIDSYSLOGPOOLALLOCATOR_H
6 : #define SOLIDSYSLOGPOOLALLOCATOR_H
7 :
8 : #include "SolidSyslogExternC.h"
9 :
10 : #include <stdbool.h>
11 : #include <stddef.h>
12 :
13 : SOLIDSYSLOG_EXTERN_C_BEGIN
14 :
15 : struct SolidSyslogPoolAllocator
16 : {
17 : bool* InUse;
18 : size_t Count;
19 : };
20 :
21 : typedef void (*SolidSyslogPoolCleanup)(size_t index, void* context);
22 :
23 : size_t SolidSyslogPoolAllocator_AcquireFirstFree(struct SolidSyslogPoolAllocator * self);
24 :
25 : bool SolidSyslogPoolAllocator_FreeIfInUse(
26 : struct SolidSyslogPoolAllocator * self,
27 : size_t index,
28 : SolidSyslogPoolCleanup cleanup,
29 : void* context
30 : );
31 :
32 128073 : static inline bool SolidSyslogPoolAllocator_IndexIsValid(const struct SolidSyslogPoolAllocator* self, size_t index)
33 : {
34 128073 : return index < self->Count;
35 : }
36 :
37 : SOLIDSYSLOG_EXTERN_C_END
38 :
39 : #endif /* SOLIDSYSLOGPOOLALLOCATOR_H */
|