- Notifications
You must be signed in to change notification settings - Fork0
Iipal/libsalloc
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Static memory allocator.
Original idea by Sergey Shevchuk (Nachos836);
Implementation by Taras Maliukh (Iipal);
Header-only library with malloc-like behavior for mapping\allocation memory on static buffer, so all work with memory mostly can be optimized and calculated at compile-time.
More details of everything documented in code.
Code logic based onthis document, which explains everything about most common malloc-like allocator implementations. Details:
- Implemented usingimplicit bidirectional free-list akaBidirectional Coalescing: Boundary Tags.
- Each allocation takes additional 16bytes in the static buffer forBoundary Tags info.
- In code, eachBoundary Tag is described in the
__s_tag_t
structure
- In code, eachBoundary Tag is described in the
- Each allocation aligned by 16bytes by default. (24 will align to 32)
- Each allocation will useBest Fit method to find a free block. Best Fit: Search the list, choose the best free block: fits, with the fewest bytes leftover.
- On
sfree
call implemented withBidirectional Coalescing with preceding free blocks. - Optional nullability checks (
_Nonnull
and_Nullable
) withSALLOC_NULLABILITY
. - All code formatted via
clang-format
(version 12.0). - No dependency on any library, even on standardlibc.
- NOTE: If you define
SALLOC_DEBUG
beforesalloc.h
include then it's will include alsostdio.h
andsalloc_trace
will useprintf
.
- NOTE: If you define
Originally it's written for
clang
only, because of its features.
All macroses, types or functions with prefixes:
__s_
,__st_
,__s2c
,__sattr_
,__salloc_
or__sfree_
are created only for internal-use purposes.
About
S-Alloc. Static memory Allocator.