All Topics
All Topics
Technology
Technology
Design
Design
Programming
Programming
Science
Science
News
News
Gaming
Gaming
Entertainment
Entertainment
Business
Business
Finance
Finance
Sports
Sports
Health
Health
Food
Food
Travel
Travel
Art
Art
Music
Music
Books
Books
Education
Education
Politics
Politics
Personal
Personal
No algorithm. No AI slop. No ads. Just RSS. Pro-human. Indie writers. Real journalism. Open web. Chronological. Hand toasted.

Introduction to the Segment Array: A Stable-Pointer Data Structure in C

By

ibobev

9mo ago· 6 min readen

Summary

The article introduces a data structure called a 'segment array,' which serves as an alternative to dynamic arrays in C, offering stable pointers and compatibility with arena allocators. The author explains its various names and implementations, providing a downloadable single-header implementation for practical use.

Key quotes

· 4 pulled
A data structure that can be used in place of dynamic arrays, has stable pointers, and works well with arena allocators.
It’s been independently discovered by different programmers over the years and so goes by different names.
A 2001 paper called it a 'levelwise-allocated pile' (bleh). Others call it an 'exponential array'. I use the name 'segment array'.
I use C in this article, but its concepts work in other languages like Zig, Rust, or C++.
Snippet from the RSS feed
My last article about generic data structures in C was written to set the stage for today’s topic: A data structure that can be used in place of dynamic arrays, has stable pointers, and works well with arena allocators. It’s been independently discovered

You might also wanna read