3 ms·
Yes, see for instance the GNU C Library “obstacks” facility; It’s clearly not object-oriented: https://www.gnu.org/software/libc/manual/html_node/Obstacks.html
by teddyh 4y ago
Yes, see for instance the GNU C Library “obstacks” facility; It’s clearly not object-oriented:
https://www.gnu.org/software/libc/manual/html_node/Obstacks.html https://www.gnu.org/software/libc/manual/html_node/Obstacks....
“An obstack is a pool of memory containing a stack of objects. You can create any number of separate obstacks, and then allocate objects in specified obstacks. Within each obstack, the last object allocated must always be the first one freed, but distinct obstacks are independent of each other.
Aside from this one constraint of order of freeing, obstacks are totally general: an obstack can contain any number of objects of any size. They are implemented with macros, so allocation is usually very fast as long as the objects are usually small. And the only space overhead per object is the padding needed to start each object on a suitable boundary.”
- cmrdporcupine 4y agoI love obstacks, after a lead at a job I was at a decade ago pointed them out to me I always look for a chance to use them, but haven't really had much of a chance. There isn't a lot of info about them though. Go hunting for performance metrics on them, or discussion of them generally and you won't find much. The glibc pages themselves don't give much justification why you would use them vs malloc, or an arena allocator, etc.