diff options
author | Guy Harris <guy@alum.mit.edu> | 2005-08-06 19:58:45 +0000 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2005-08-06 19:58:45 +0000 |
commit | f618b54d368be8ee5b26c982f492d4132cda1f16 (patch) | |
tree | 4b2184339504000339e2cc5ef6405aa2320fc255 /epan/except.h | |
parent | b003633f3bc22bf99d9c1afcddb3b27ecffc9b30 (diff) |
Support throwing an exception with a null message pointer, and have the
message not be const (as we generate messages with "g_strdup_sprintf()",
which means they need to be freed; using a null message means that we
don't have to use a special string for exceptions with no message, and
don't have to worry about not freeing that).
Have THROW() throw an exception with a null message pointer. (This
means that you crash if you throw DissectorError with THROW(). Don't do
that - it means you don't get a more detailed explanation of the
dissector problem. Use the DISSECTOR_ASSERT, etc. macros in
epan/proto.h instead.)
Free the exception message for DissectorError, as it's mallocated.
svn path=/trunk/; revision=15250
Diffstat (limited to 'epan/except.h')
-rw-r--r-- | epan/except.h | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/epan/except.h b/epan/except.h index 459555d210..741cd0eabe 100644 --- a/epan/except.h +++ b/epan/except.h @@ -18,6 +18,15 @@ * $Name: $ */ +/* + * Modified to support throwing an exception with a null message pointer, + * and to have the message not be const (as we generate messages with + * "g_strdup_sprintf()", which means they need to be freed; using + * a null message means that we don't have to use a special string + * for exceptions with no message, and don't have to worry about + * not freeing that). + */ + #ifndef XCEPT_H #define XCEPT_H @@ -42,7 +51,7 @@ typedef struct { typedef struct { except_id_t volatile except_id; - const char *volatile except_message; + char *volatile except_message; void *volatile except_dyndata; } except_t; @@ -82,13 +91,13 @@ extern struct except_stacknode *except_pop(void); extern int except_init(void); extern void except_deinit(void); extern void except_rethrow(except_t *); -extern void except_throw(long, long, const char *); -extern void except_throwd(long, long, const char *, void *); +extern void except_throw(long, long, char *); +extern void except_throwd(long, long, char *, void *); extern void except_throwf(long, long, const char *, ...); extern void (*except_unhandled_catcher(void (*)(except_t *)))(except_t *); extern unsigned long except_code(except_t *); extern unsigned long except_group(except_t *); -extern const char *except_message(except_t *); +extern char *except_message(except_t *); extern void *except_data(except_t *); extern void *except_take_data(except_t *); extern void except_set_allocator(void *(*)(size_t), void (*)(void *)); |