ebassi / graphene

A thin layer of graphic data types

Home Page:http://ebassi.github.io/graphene

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Option to specify custom allocators

legends2k opened this issue · comments

graphene_aligned_alloc and graphene_aligned_free are used to allocate memory but it'd be beneficial to allow specifying alloc/dealloc functions for applications like games where custom memory allocators are commonplace to control memory usage patterns. An option to override the alloc/free functions globally for the library would be useful. Example: stb.

Not a huge fan, to be honest.

The expected use of Graphene types is on the stack, or inlined inside structures; the heap allocation code is mostly there for integration with non-C users, consuming the Graphene API through bindings. That's why the whole graphene_aligned_alloc()/graphene_aligned_free() API is private.

Additionally, the alignment requirements are very strict; generic allocation code might very well end up breaking those constraints.

The expected use of Graphene types is on the stack, or inlined inside structures; the heap allocation code is mostly there for integration with non-C users, consuming the Graphene API through bindings.

Aah... then it's a non-issue for C or C++ programs which integrate graphene and use in their hot paths. Otherwise small allocs and dealloc in such loops will lead to drops in performance and hence my request on allowing to use custom allocators. But if it doesn't do any freestore allocation for C and C++ programs, we're good. Thanks!

Aside: Thanks for the nice library :)