Design¶

Requirements¶

• Add my own max_align_t like musl’s (a struct that contains a long long a long double, intmax_t, a char pointer, and a function pointer).

• How do I account for SIMD types? Maybe allow users to set max alignment request in a context stack?

• Two types of allocators:

• Stack allocator, meant for things allocated on the helper stacks. See the strucon (structured concurrency) requirements document.

• General allocator, meant for everything else.

• Two types of destructors:

• Destructors, that destruct anything the item uses.

• Should have a convention of *_destroy().

• The stack allocator should use this one.

• Freer, which frees the item. (Default is no free.)

• Should have a convention of *_free().

• General allocator should use this one, and it should be required to call the Destructor if it exists.

• Is this one even necessary? I think so, when user data structures store things like the vectors. Since it will just be heap-allocated in that case, it should still be able to free itself.

• However, all these things would do is call the general allocator free() after calling their destructors.

• Add a way to do reference counting?

• It could do something like mutexes in the strucon document, where it “owns” the item it guards.

• Must also take care of alignment.

• Of course, Destructor would decrement the count and destroy the item if necessary.

General Allocator¶

• Should take the type it is allocating.

• If the allocation is meant to grow or shrink, there should be a separate routine for that.

• If an allocation that is allocated with the non-grow routine is tried to be resized, the allocator should error.

• Allow requesting alignment?

Stack Pool¶

• Should take the type it is allocating.

• May also take the number of elements, but cannot grow or shrink.

• Maybe allow it to be pulled from the stack? The application would pay for that (yc should make no effort to reclaim the memory), but if they want to do that, maybe I should let them.

• Can only be freed in LIFO order. There is no general free routine.

• Should be able to request alignment.