Re:Show HN: Smart pointers for the C programming language
by rileymat on Thursday January 15, 2015 @01:18AM
(#8891179)
Can someone explain the magic sauce that makes this work?
[ Parent
| on HN ]
Re:Show HN: Smart pointers for the C programming language
by Snaipe on Thursday January 15, 2015 @03:11AM
(#8891409)
I pretty much explain all that in the article[1], but here is the gist of it:
* I implemented smalloc and sfree to respectively allocate and deallocate a memory block with prepended metadata
* I use a GNU variable attribute called cleanup to run sfree when the variable goes out of scope
* I made some macros to have some syntactic sugar on top of that