| |||||
| Bfd3 Core Library 〈NEWEST ⇒〉bfd3::FixedString<64> filename = "config_"; filename.append("data.bin"); const char* cstr = filename.c_str(); // null-terminated For network protocols or file I/O, endianness and padding matter. The core library offers binary streams with explicit byte ordering. // Thread 2 (consumer) Event ev; while (eventBus.pop(ev)) dispatch(ev); Bfd3 core library 🚫 Pitfall 1: Forgetting Intrusive Container Node Lifetime If an object with an intrusive list node is destroyed while still in a list, the list's next/prev pointers become dangling. Always remove before destruction. 🚫 Pitfall 2: Mixing Allocators Memory allocated from bfd3::MemoryArena must not be freed with delete . Use the arena's own reset mechanism. ✅ Best Practice: Use RAII Wrappers Even with custom memory, encapsulate allocations in small scope-bound objects. bfd3::FixedString<64> filename = "config_"; filename This pattern is a game-changer for per-frame allocations in games or message processing in servers. Unlike STL containers that own their elements, intrusive containers require the element type to embed the linking pointers. This allows an object to belong to multiple containers simultaneously and avoids separate heap allocations for nodes. Always remove before destruction #include <bfd3/MemoryArena.h> bfd3::MemoryArena arena(1024 * 1024); // 1 MB arena void* buffer = arena.alloc(256); // allocate 256 bytes arena.reset(); // free all allocations at once | Operation | STL (std::vector) | Bfd3 core library | Improvement | |------------------------------------|-------------------|------------------|-------------| | 1M int insert at back | 12.3 ms | 11.1 ms | 9% | | 100k small string push (FixedString)| 45.2 ms (string) | 8.4 ms | 438% | | Multi-producer queue throughput | 8.2M ops/sec (mutex) | 24.5M ops/sec | 199% | | Arena allocation (1M blocks) | 345 ms (new/delete) | 87 ms | 296% | |
| |||
|
| ||||
| |||||