If you want garbage collection in C, have a look at the Hans Boehm garbage collection library.
Shared ptr removes much of the necessity of handling object deletion, but has a number of complications: only one shared pointer can hold the pointer at a time. You might want to look also at Boost's smart_ptr pointer handling and related classes.
But shared_ptr, and Boost, is C++. You will struggle to achieve this in C: shared_ptr relies on operator overloading to achieve its magic. Without operator overloading, you have no way of knowing if someone, somewhere, is holding a copy of your pointer. (This is a problem also in C++, but the operator overloading reduces the risk if you use shared_ptr throughout your code.)
I would definitely recommend Hans Boehm instead.