Skip to content

Commit 455fc22

Browse files
erikcededsiper
authored andcommitted
mem: make flb_malloc_{p,mod} extern
Move definitions to its own file to avoid breaking the C++ one definition rule, improving the integration with the C++ code in flb-simdutf-connector. Signed-off-by: Erik Cederberg <[email protected]>
1 parent b66b937 commit 455fc22

File tree

3 files changed

+28
-2
lines changed

3 files changed

+28
-2
lines changed

include/fluent-bit/flb_mem.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@
5050
/*
5151
* Return 1 or 0 based on a probability.
5252
*/
53-
int flb_malloc_p;
54-
int flb_malloc_mod;
53+
extern int flb_malloc_p;
54+
extern int flb_malloc_mod;
5555

5656
static inline int flb_fuzz_get_probability(int val) {
5757
flb_malloc_p += 1;

src/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ set(src
9191
flb_cfl_ra_key.c
9292
flb_cfl_record_accessor.c
9393
flb_conditionals.c
94+
flb_mem.c
9495
)
9596

9697
# Config format

src/flb_mem.c

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2+
3+
/* Fluent Bit
4+
* ==========
5+
* Copyright (C) 2015-2025 The Fluent Bit Authors
6+
*
7+
* Licensed under the Apache License, Version 2.0 (the "License");
8+
* you may not use this file except in compliance with the License.
9+
* You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing, software
14+
* distributed under the License is distributed on an "AS IS" BASIS,
15+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
* See the License for the specific language governing permissions and
17+
* limitations under the License.
18+
*/
19+
20+
#include <fluent-bit/flb_info.h>
21+
22+
#ifdef FLB_HAVE_TESTS_OSSFUZZ
23+
int flb_malloc_p;
24+
int flb_malloc_mod;
25+
#endif

0 commit comments

Comments
 (0)