Buddy Alloc Versions Save

A single header buddy memory allocator for C & C++

v1.1.0

5 months ago
  • Add a parameter to buddy_realloc that allows it to ignore data. Useful for resizing buffers when there is no longer any interest in their content.
  • Minor style and repo changes.

v1.0.0

7 months ago

External changes:

  • buddy_walk callback is now invoked for free slots in addition to allocated ones and has an extra parameter to distinguish between free and allocated.
  • buddy_fragmentation return type is now an unsigned char that ranges between 0 and 255 and no float types are used. This way fragmentation can be reported when used in environments that don't support the float type.

Internal changes:

  • A static inline two_to_the_power_of helper function that returns size_t is used in place of manual power of two calculations.
  • The fast square root algorithm used in the fragmentation formula has been replaced with an integer square root algorithm by Martin Guy, 1985.

Misc:

Two years and nine months have passed since this project started and it has now reached the 1.0.0 milestone. Thanks to all contributors and users for their interest in it.

v0.9

8 months ago
  • Remove FAMs and {0} initializers to facilitate interop with strict C++ compilers
    • Clang generates identical code with FAMs and without FAMs
    • GCC generates almost-identical code
  • Make the debug functions non-static so that they can be used by code in other units
  • Include stdio.h only when BUDDY_PRINTF is not defined
  • Add a macro for C++ name mangling

v0.8

10 months ago
  • The allocator is now easier to use within a linux kernel/module.
    • Conforms to the c90-style variable declarations in functions
    • New defines BUDDY_PRINTF, BUDDY_HEADER and BUDDY_FRAG_OPTIONAL added to allow conditional inclusion of functionality and setting a suitable printf-like function for the debug functions.
  • Fixed some issues with explicit alignment init functions
  • Fixed UB on invalid free calls

v0.7.2

10 months ago
  • Additional performance improvements
  • Stricter compile-time checks
  • Fixed code coverage reporting and got coverage back to 100%.

v0.7.1

11 months ago

This is a significant performance update achieved by reducing the number of tree reads during allocation.

Running bench.c using gcc -O2 on v0.7 takes 20 seconds vs 16 seconds on v0.7.1 Running bench.c using clang -O3 on v0.7 takes 16 seconds vs 13 seconds on v0.7.1

v0.7

11 months ago
  • Add buddy_arena_free_size that reports the remaining free space in the arena. Note that this is a sum of all slots and not necessarily continuous memory.
  • Support setting alignment as an argument to init and sizeof functions. This way an application can use multiple allocator instances with different alignments. The BUDDY_ALLOC_ALIGN define is still supported. This is a change in the internal structure of the allocator which can impact serialized instances. There's no impact to regular users.
  • Always use the optimal fit algorithm, drop support for the left-bias one.
  • Drop the BUDDY_ALLOC_SAFETY define, always use safety checks.
  • Jump to version v0.7. v0.6 was a botched release that was deleted

v0.5.1

1 year ago
  • Added support for compiling with MSVC
  • Made the library usable from C++

v0.5

1 year ago
  • Made all tests work on both 64-bit and 32-bit platforms
  • Added a buddy_fragmentation function that measures and reports fragmentation in the arena
  • Added buddy_set_left_bias and buddy_set_optimal_fit functions to configure allocation behavior on demand
  • Internal optimizations and better code reuse

v0.4.1

1 year ago
  • The tests now run on powerpc (32-bit, big-endian), powerpc64 (64-bit, big-endian), aarch64 (64-bit, little-endian) and i686 (32-bit, little-endian)
  • Fixed unaligned access, run tests with UBSan
  • Fixed an internal highest bit position function on 32-bit for SIZE_MAX
  • Fixed two invalid printf invocations in internal debug functions