diff options
-rw-r--r-- | epan/except.h | 23 | ||||
-rw-r--r-- | epan/exceptions.h | 7 |
2 files changed, 30 insertions, 0 deletions
diff --git a/epan/except.h b/epan/except.h index 407be9d83c..68fa58e7fc 100644 --- a/epan/except.h +++ b/epan/except.h @@ -143,6 +143,29 @@ extern void except_free(void *); except_cl.except_func(except_cl.except_context); \ } + +/* --- Variants to allow nesting of except_cleanup_push w/o "shadowing" variables */ +#define except_cleanup_push_pfx(pfx, F, C) \ + { \ + struct except_stacknode pfx##_except_sn; \ + struct except_cleanup pfx##_except_cl; \ + except_setup_clean(&pfx##_except_sn, &pfx##_except_cl, F, C) + +#define except_cleanup_pop_pfx(pfx, E) \ + except_pop(); \ + if (E) \ + pfx##_except_cl.except_func(pfx##_except_cl.except_context);\ + } + +#define except_checked_cleanup_pop_pfx(pfx, F, E) \ + except_pop(); \ + assert (pfx##_except_cl.except_func == (F)); \ + if (E) \ + pfx##_except_cl.except_func(pfx##_except_cl.except_context);\ + } +/* ---------- */ + + #define except_try_push(ID, NUM, PPE) \ { \ struct except_stacknode except_sn; \ diff --git a/epan/exceptions.h b/epan/exceptions.h index 62a631992d..92b91ca29f 100644 --- a/epan/exceptions.h +++ b/epan/exceptions.h @@ -341,4 +341,11 @@ #define CLEANUP_POP except_cleanup_pop(0) #define CLEANUP_CALL_AND_POP except_cleanup_pop(1) +/* Variants to allow nesting of except_cleanup_push w/o "shadowing" variables */ +#define CLEANUP_PUSH_PFX(pfx,f,a) except_cleanup_push_pfx(pfx,(f),(a)) +#define CLEANUP_POP_PFX(pfx) except_cleanup_pop_pfx(pfx,0) +#define CLEANUP_CALL_AND_POP_PFX(pfx) except_cleanup_pop_pfx(pfx,1) + + + #endif /* __EXCEPTIONS_H__ */ |