forked from osmocom/wireshark
Cleanup tvb
- make tvb_ops->tvb_size a gsize field, not function call - remove not needed forward declaration / forward line svn path=/trunk/; revision=51141
This commit is contained in:
parent
af134c29ca
commit
b67492bbc0
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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 */
|
||||
|
|
Loading…
Reference in New Issue