Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

S-Alloc. Static memory Allocator.

NotificationsYou must be signed in to change notification settings

Iipal/libsalloc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Static memory allocator.

Original idea by Sergey Shevchuk (Nachos836);

Implementation by Taras Maliukh (Iipal);

General Idea

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.

Internal

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
  • 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.
  • Onsfree call implemented withBidirectional Coalescing with preceding free blocks.
  • Optional nullability checks (_Nonnull and_Nullable) withSALLOC_NULLABILITY.
  • All code formatted viaclang-format (version 12.0).
  • No dependency on any library, even on standardlibc.
    • NOTE: If you defineSALLOC_DEBUG beforesalloc.h include then it's will include alsostdio.h andsalloc_trace will useprintf.

Originally it's written forclang 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.


[8]ページ先頭

©2009-2025 Movatter.jp