diff options
author | Guy Harris <guy@alum.mit.edu> | 2002-05-05 21:07:52 +0000 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2002-05-05 21:07:52 +0000 |
commit | 33e80cec6446e46c9c19fa66d048b0b6acb07e2f (patch) | |
tree | c5b48faed5f532ef7f2fb30ed33a6aedb537b978 /epan | |
parent | d612dab6df72f48bdc50c89206feee9b242fd439 (diff) |
Have "tvb_ensure_length_remaining()" directly call
"compute_offset_length()", and throw the exception it returns, rather
than calling "tvb_length_remaining()" and throw BoundsError if it
returns -1; this allows us to add additional exceptions without having
to change "tvb_ensure_length_remaining()".
Make "_tvb_get_nstringz()" static, as it's not used outside "tvbuff.c".
svn path=/trunk/; revision=5397
Diffstat (limited to 'epan')
-rw-r--r-- | epan/tvbuff.c | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/epan/tvbuff.c b/epan/tvbuff.c index 4a1de7974b..1c0ef6ecfd 100644 --- a/epan/tvbuff.c +++ b/epan/tvbuff.c @@ -9,7 +9,7 @@ * the data of a backing tvbuff, or can be a composite of * other tvbuffs. * - * $Id: tvbuff.c,v 1.35 2002/05/05 00:57:59 guy Exp $ + * $Id: tvbuff.c,v 1.36 2002/05/05 21:07:52 guy Exp $ * * Copyright (c) 2000 by Gilbert Ramirez <gram@alumni.rice.edu> * @@ -610,18 +610,15 @@ tvb_length_remaining(tvbuff_t *tvb, gint offset) guint tvb_ensure_length_remaining(tvbuff_t *tvb, gint offset) { - gint retval; + guint abs_offset, abs_length; + int exception; - retval = tvb_length_remaining(tvb, offset); + g_assert(tvb->initialized); - if (retval == -1) { - THROW(ReportedBoundsError); - return -1; /* squelch compiler complaint */ - } - else { - g_assert(retval >= 0); - return retval; + if (!compute_offset_length(tvb, offset, -1, &abs_offset, &abs_length, &exception)) { + THROW(exception); } + return abs_length; } @@ -1599,7 +1596,7 @@ tvb_format_text(tvbuff_t *tvb, gint offset, gint size) * *bytes_copied will contain the number of bytes actually copied, * including the terminating-NUL. */ -gint +static gint _tvb_get_nstringz(tvbuff_t *tvb, gint offset, guint maxlength, guint8* buffer, gint *bytes_copied) { |