Possible Duplicate:
Smart pointers/safe memory management for C?
I have an embedded application where I am allocating an object in dynamic memory and passing it around to other modules.
I would like to create a smart pointer to this object. There are many examples in C++ for using and implementing smart pointers.
I am looking for a C language only implementation of a smart pointer.
Thanks.
Yes, I think it’s impossible (or at least, not as useful) because of what @KennyTM says. Smart pointers are possible because of constructors and destructors being automatically called. Otherwise you’ll have to call reference() and unreference() yourself. Still useful?
Also, see this previous, very related SO question: Smart pointers/safe memory management for C?