Skip to content

Stack allocator memory optimization - #82

Merged
nihiL7331 merged 5 commits into
mainfrom
arena-alloc
Sep 18, 2026
Merged

nihiL7331 merged 5 commits into
mainfrom
arena-alloc

Conversation

@nihiL7331

Copy link
Copy Markdown
Owner

This PR implements a stack allocator (linear allocator with rewinding capabilities), used to optimize scenarios where temporary heap memory is necessary.
The scratch is used throughout the whole kitty graphics protocol logic, in OSC52 and during font baking when oversample is turned on.

Changes:

  • Due to the usage of _Static_assert and _Alignof, the C standard was bumped from C99 to C11.
  • Because of the structure of the codebase, there's really not a reason to not keep functions not inline. That's why all of the functions got the inline keyword. That's because every function is either called once or is tiny enough, where the compiler inlining the function doesn't affect the binary size at all.
    -While rewriting kitty logic, certain parts got optimized:
    • cropping is now in-place,
    • scaled image is placed on top of the original image,
    • all memory is freed just when its not needed during the kitty render loop.
  • Sixel got a small optimization, where on commit there's no additional allocation, instead using the same in-place trick as in image scaling in kitty.
  • Changed the default SFTE_TERM_ALT_SCREEN value back to 1.

@nihiL7331 nihiL7331 self-assigned this Sep 18, 2026
@nihiL7331
nihiL7331 merged commit 6337ead into main Sep 18, 2026
1 check passed
@nihiL7331
nihiL7331 deleted the arena-alloc branch September 18, 2026 03:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant