summaryrefslogtreecommitdiff
path: root/epan/exceptions.h
diff options
context:
space:
mode:
authorLuis Ontanon <luis.ontanon@gmail.com>2007-04-03 22:06:31 +0000
committerLuis Ontanon <luis.ontanon@gmail.com>2007-04-03 22:06:31 +0000
commit96384817ecdd9d9907baba74076ea49bd9d2fadf (patch)
tree34066e7d95d6b4aa5d06fa1d4aebc89c1427c714 /epan/exceptions.h
parent7e8012faa5cd318ea4ab7b74e900f86e12dac51b (diff)
downloadwireshark-96384817ecdd9d9907baba74076ea49bd9d2fadf.tar.gz
Make sure that when a windows exception is thrown ENDTRY gets evaluated.
fix for one of the various issues that cause bug 1334 svn path=/trunk/; revision=21332
Diffstat (limited to 'epan/exceptions.h')
-rw-r--r--epan/exceptions.h21
1 files changed, 17 insertions, 4 deletions
diff --git a/epan/exceptions.h b/epan/exceptions.h
index acf9b78a27..100a0fb151 100644
--- a/epan/exceptions.h
+++ b/epan/exceptions.h
@@ -74,6 +74,7 @@
#define OutOfMemoryError 6
+
/* Usage:
*
* TRY {
@@ -171,7 +172,17 @@
* RETHROW, and don't reenter FINALLY if a
* different exception is thrown */
-#define TRY \
+#ifdef _MSC_VER
+#define WINTRY __try {
+#define WINENDTRY_BEGIN } __finally {
+#define WINENDTRY_END }
+#else
+#define WINTRY
+#define WINENDTRY_BEGIN
+#define WINENDTRY_END
+#endif
+
+#define TRY /**/\
{\
except_t *exc; \
volatile int except_state = 0; \
@@ -184,15 +195,17 @@
except_state &= ~EXCEPT_CAUGHT; \
\
if (except_state == 0 && exc == 0) \
- /* user's code goes here */
+ WINTRY /* user's code goes here */
+
#define ENDTRY \
- /* rethrow the exception if necessary */ \
+ WINENDTRY_BEGIN /* rethrow the exception if necessary */ \
if(!(except_state&EXCEPT_CAUGHT) && exc != 0) \
except_rethrow(exc); \
- except_try_pop();\
+ except_try_pop(); WINENDTRY_END\
}
+
/* the (except_state |= EXCEPT_CAUGHT) in the below is a way of setting
* except_state before the user's code, without disrupting the user's code if
* it's a one-liner.