#include #include #include "../memory/util.h" #define AUTO_FREE __attribute__((cleanup(scoped_free))) typedef struct Point { int x; int y; } Point; void scoped_free(void *pointer) { printf("Scoped free invoked %p\n",pointer); void **pp = (void**)pointer; free(*pp); } int main(int argc, char **argv) { AUTO_FREE Point *p1 = (Point *)malloc(sizeof(Point)); p_mem("P1",p1); AUTO_FREE Point *p2 = (Point *)malloc(sizeof(Point)); p_mem("P2",p2); }