Skip to content

Instantly share code, notes, and snippets.

@McRaeAlex
McRaeAlex / twc_stretchy_buffer.h
Last active November 28, 2019 07:05
This is a gist that is a alternative implementation of the stb stretchy buffers. I found out about stretchy buffers through Our Machinery (https://ourmachinery.com/post/minimalist-container-library-in-c-part-1/) and found it really interesting! Not sure if this is considered "good" c but it did work for my tests
#ifndef TWC_STRETCHY_BUFFER
#define TWC_STRETCHY_BUFFER
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
// This changes how much the arrays capacity the arrays gain when reallocated
#define capacity_increment \
5