diff --git a/epan/tvbuff-int.h b/epan/tvbuff-int.h index e828af7647..e57d176528 100644 --- a/epan/tvbuff-int.h +++ b/epan/tvbuff-int.h @@ -29,7 +29,7 @@ struct tvbuff; struct tvb_ops { - gsize (*tvb_size)(void); + gsize tvb_size; void (*tvb_free)(struct tvbuff *tvb); guint (*tvb_offset)(const struct tvbuff *tvb, guint counter); const guint8 *(*tvb_get_ptr)(struct tvbuff *tvb, guint abs_offset, guint abs_length); diff --git a/epan/tvbuff.c b/epan/tvbuff.c index ccda1a4832..34f49923e6 100644 --- a/epan/tvbuff.c +++ b/epan/tvbuff.c @@ -51,10 +51,6 @@ #include "charsets.h" #include "proto.h" /* XXX - only used for DISSECTOR_ASSERT, probably a new header file? */ -static const guint8* -ensure_contiguous_no_exception(tvbuff_t *tvb, const gint offset, const gint length, - int *pexception); - static guint64 _tvb_get_bits64(tvbuff_t *tvb, guint bit_offset, const gint total_no_of_bits); @@ -62,7 +58,7 @@ tvbuff_t * tvb_new(const struct tvb_ops *ops) { tvbuff_t *tvb; - gsize size = (ops->tvb_size) ? ops->tvb_size() : sizeof(*tvb); + gsize size = ops->tvb_size ? ops->tvb_size : sizeof(*tvb); g_assert(size >= sizeof(*tvb)); @@ -92,7 +88,7 @@ tvb_free_internal(tvbuff_t *tvb) if (tvb->ops->tvb_free) tvb->ops->tvb_free(tvb); - size = (tvb->ops->tvb_size) ? tvb->ops->tvb_size() : sizeof(*tvb); + size = (tvb->ops->tvb_size) ? tvb->ops->tvb_size : sizeof(*tvb); g_slice_free1(size, tvb); } @@ -633,7 +629,6 @@ ensure_contiguous_no_exception(tvbuff_t *tvb, const gint offset, const gint leng if (tvb->real_data) return tvb->real_data + abs_offset; - if (tvb->ops->tvb_get_ptr) return tvb->ops->tvb_get_ptr(tvb, abs_offset, abs_length); diff --git a/epan/tvbuff_composite.c b/epan/tvbuff_composite.c index ade37b1025..b02919238d 100644 --- a/epan/tvbuff_composite.c +++ b/epan/tvbuff_composite.c @@ -46,12 +46,6 @@ struct tvb_composite { tvb_comp_t composite; }; -static gsize -composite_sizeof(void) -{ - return sizeof(struct tvb_composite); -} - static void composite_free(tvbuff_t *tvb) { @@ -183,7 +177,8 @@ composite_memcpy(tvbuff_t *tvb, void* _target, guint abs_offset, guint abs_lengt } static const struct tvb_ops tvb_composite_ops = { - composite_sizeof, /* size */ + sizeof(struct tvb_composite), /* size */ + composite_free, /* free */ composite_offset, /* offset */ composite_get_ptr, /* get_ptr */ diff --git a/epan/tvbuff_real.c b/epan/tvbuff_real.c index e6b94463eb..e3368beba0 100644 --- a/epan/tvbuff_real.c +++ b/epan/tvbuff_real.c @@ -36,12 +36,6 @@ struct tvb_real { tvbuff_free_cb_t free_cb; }; -static gsize -real_sizeof(void) -{ - return sizeof(struct tvb_real); -} - static void real_free(tvbuff_t *tvb) { @@ -62,7 +56,8 @@ real_offset(const tvbuff_t *tvb _U_, const guint counter) } static const struct tvb_ops tvb_real_ops = { - real_sizeof, /* size */ + sizeof(struct tvb_real), /* size */ + real_free, /* free */ real_offset, /* offset */ NULL, /* get_ptr */ diff --git a/epan/tvbuff_subset.c b/epan/tvbuff_subset.c index b5034b3f12..806b2ac44e 100644 --- a/epan/tvbuff_subset.c +++ b/epan/tvbuff_subset.c @@ -46,12 +46,6 @@ struct tvb_subset { tvb_backing_t subset; }; -static gsize -subset_sizeof(void) -{ - return sizeof(struct tvb_subset); -} - static guint subset_offset(const tvbuff_t *tvb, const guint counter) { @@ -102,7 +96,8 @@ subset_clone(tvbuff_t *tvb, guint abs_offset, guint abs_length) } static const struct tvb_ops tvb_subset_ops = { - subset_sizeof, /* size */ + sizeof(struct tvb_subset), /* size */ + NULL, /* free */ subset_offset, /* offset */ subset_get_ptr, /* get_ptr */ diff --git a/frame_tvbuff.c b/frame_tvbuff.c index 27db55765e..b6d4545113 100644 --- a/frame_tvbuff.c +++ b/frame_tvbuff.c @@ -143,12 +143,6 @@ frame_pbrk_guint8(tvbuff_t *tvb, guint abs_offset, guint limit, const guint8 *ne return tvb_pbrk_guint8(tvb, abs_offset, limit, needles, found_needle); } -static gsize -frame_sizeof(void) -{ - return sizeof(struct tvb_frame); -} - static guint frame_offset(const tvbuff_t *tvb _U_, const guint counter) { @@ -159,7 +153,8 @@ frame_offset(const tvbuff_t *tvb _U_, const guint counter) static tvbuff_t *frame_clone(tvbuff_t *tvb, guint abs_offset, guint abs_length); static const struct tvb_ops tvb_frame_ops = { - frame_sizeof, /* size */ + sizeof(struct tvb_frame), /* size */ + frame_free, /* free */ frame_offset, /* offset */ frame_get_ptr, /* get_ptr */