1 #ifndef KRB5_CLEANUP 2 #define KRB5_CLEANUP 3 4 struct cleanup { 5 void * arg; 6 void (*func)(void *); 7 }; 8 9 #define CLEANUP_INIT(x) \ 10 struct cleanup cleanup_data[x]; \ 11 int cleanup_count = 0; 12 13 #define CLEANUP_PUSH(x, y) \ 14 cleanup_data[cleanup_count].arg = x; \ 15 cleanup_data[cleanup_count].func = y; \ 16 cleanup_count++; 17 18 #define CLEANUP_POP(x) \ 19 if ((--cleanup_count) && x && (cleanup_data[cleanup_count].func)) \ 20 cleanup_data[cleanup_count].func(cleanup_data[cleanup_count].arg); 21 22 #define CLEANUP_DONE() \ 23 while(cleanup_count--) \ 24 if (cleanup_data[cleanup_count].func) \ 25 cleanup_data[cleanup_count].func(cleanup_data[cleanup_count].arg); 26 27 28 #endif 29