CFL is a compact C library of data structures and low-level utilities used by
Fluent Bit and its companion telemetry libraries. It
provides dynamic strings, intrusive lists, typed variants, arrays, key/value
containers, hashing, checksums, atomics, and an optional arena allocator.
CFL started as a C library for Fluent Bit, a.k.a. C:\Floppy.
The library is designed to be embedded. Callers can include the complete public
interface with:
#include <cfl/cfl.h>
Individual headers under include/cfl/ can be used when a component needs a
smaller interface.
Highlights
Small C API with no required runtime framework.
Typed recursive values through cfl_variant, cfl_array, and cfl_kvlist.
Length-aware dynamic strings through cfl_sds.
Intrusive lists and lightweight string key/value entries.
Portable 64-bit atomics and time helpers.
xxHash wrappers and CRC32C checksums.
Optional arenas for allocation-heavy, bounded object graphs and arbitrary
request-lifetime objects.
CMake support for embedding, installation, tests, and benchmarks.
Core data structures
Interface
Purpose
cfl_sds
Growable binary-safe strings with explicit length and capacity
cfl_list
Intrusive doubly linked lists and safe iteration helpers
cfl_kv
String key/value entries stored in a CFL list
cfl_variant
Tagged bool, integer, double, null, reference, string, bytes, array, or map value
cfl_array
Ordered collection of variants
cfl_kvlist
String-keyed map of variants
cfl_object
Generic wrapper for a variant, array, or key/value list
cfl_arena
Optional shared allocator for bounded CFL object graphs
Heap-backed constructors remain the default. Applications that construct and
discard complete variant graphs can opt into cfl_arena; see
ARENA.md for its ownership model, API, examples, and tuning advice.
Utility interfaces
cfl_atomic: 64-bit compare-exchange, store, and load operations with
platform-specific backends.
cfl_time: wall-clock timestamps in nanoseconds.
cfl_hash: xxHash 64-bit and 128-bit wrappers.
cfl_checksum: CRC32C checksums.
cfl_utils: string splitting, including quote-aware parsing.
cfl_log: runtime error-reporting helpers.
cfl_compat, cfl_found, and cfl_info: platform and build integration.
Build
CFL requires CMake 3.20 or newer and a C compiler:
CFL
CFL is a compact C library of data structures and low-level utilities used by Fluent Bit and its companion telemetry libraries. It provides dynamic strings, intrusive lists, typed variants, arrays, key/value containers, hashing, checksums, atomics, and an optional arena allocator.
CFL started as a C library for Fluent Bit, a.k.a.
C:\Floppy.The library is designed to be embedded. Callers can include the complete public interface with:
Individual headers under
include/cfl/can be used when a component needs a smaller interface.Highlights
cfl_variant,cfl_array, andcfl_kvlist.cfl_sds.Core data structures
cfl_sdscfl_listcfl_kvcfl_variantcfl_arraycfl_kvlistcfl_objectcfl_arenaHeap-backed constructors remain the default. Applications that construct and discard complete variant graphs can opt into
cfl_arena; see ARENA.md for its ownership model, API, examples, and tuning advice.Utility interfaces
cfl_atomic: 64-bit compare-exchange, store, and load operations with platform-specific backends.cfl_time: wall-clock timestamps in nanoseconds.cfl_hash: xxHash 64-bit and 128-bit wrappers.cfl_checksum: CRC32C checksums.cfl_utils: string splitting, including quote-aware parsing.cfl_log: runtime error-reporting helpers.cfl_compat,cfl_found, andcfl_info: platform and build integration.Build
CFL requires CMake 3.20 or newer and a C compiler:
To build and run the unit tests:
Useful configuration options are:
CFL_DEVNoCFL_TESTSNoCFL_BENCHMARKSNoCFL_INSTALL_BUNDLED_XXHASH_HEADERSYesFor arena performance and memory comparisons, see benchmarks/README.md.
Embedding with CMake
Projects commonly embed CFL with
add_subdirectoryand link the static target:Applications using installed headers can include either
<cfl/cfl.h>or the specific module headers they require.API conventions
cfl_prefix.NULLwhen allocation or validation fails.Documentation
include/cfl/describe each supported interface.CFL_TESTSand run the suite through CTest as shown above.License
CFL is distributed under the Apache License 2.0.
Authors
Copyright is assigned to the CFL Authors. The contributor list is available on GitHub.