From Ed Beroset via https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=8416 :
Remove C++ incompatibilities from tvbparse and tvbuff svn path=/trunk/; revision=48025
This commit is contained in:
parent
5a37615eeb
commit
95938370bd
106
epan/tvbparse.c
106
epan/tvbparse.c
|
@ -92,7 +92,7 @@ static tvbparse_elem_t* new_tok(tvbparse_t* tt,
|
|||
if (TVBPARSE_DEBUG & TVBPARSE_DEBUG_NEWTOK) g_warning("new_tok: id=%i offset=%u len=%u",id,offset,len);
|
||||
#endif
|
||||
|
||||
tok = ep_alloc(sizeof(tvbparse_elem_t));
|
||||
tok = (tvbparse_elem_t *)ep_alloc(sizeof(tvbparse_elem_t));
|
||||
|
||||
tok->tvb = tt->tvb;
|
||||
tok->id = id;
|
||||
|
@ -166,7 +166,7 @@ tvbparse_wanted_t* tvbparse_char(const int id,
|
|||
const void* data,
|
||||
tvbparse_action_t before_cb,
|
||||
tvbparse_action_t after_cb) {
|
||||
tvbparse_wanted_t* w = g_malloc0(sizeof(tvbparse_wanted_t));
|
||||
tvbparse_wanted_t* w = (tvbparse_wanted_t *)g_malloc0(sizeof(tvbparse_wanted_t));
|
||||
|
||||
w->condition = cond_char;
|
||||
w->id = id;
|
||||
|
@ -227,7 +227,7 @@ tvbparse_wanted_t* tvbparse_chars(const int id,
|
|||
const void* data,
|
||||
tvbparse_action_t before_cb,
|
||||
tvbparse_action_t after_cb) {
|
||||
tvbparse_wanted_t* w = g_malloc0(sizeof(tvbparse_wanted_t));
|
||||
tvbparse_wanted_t* w = (tvbparse_wanted_t *)g_malloc0(sizeof(tvbparse_wanted_t));
|
||||
|
||||
w->condition = cond_chars;
|
||||
w->id = id;
|
||||
|
@ -279,7 +279,7 @@ tvbparse_wanted_t* tvbparse_not_char(const int id,
|
|||
const void* data,
|
||||
tvbparse_action_t before_cb,
|
||||
tvbparse_action_t after_cb) {
|
||||
tvbparse_wanted_t* w = g_malloc0(sizeof(tvbparse_wanted_t));
|
||||
tvbparse_wanted_t* w = (tvbparse_wanted_t *)g_malloc0(sizeof(tvbparse_wanted_t));
|
||||
|
||||
w->condition = cond_not_char;
|
||||
w->id = id;
|
||||
|
@ -341,7 +341,7 @@ tvbparse_wanted_t* tvbparse_not_chars(const int id,
|
|||
const void* data,
|
||||
tvbparse_action_t before_cb,
|
||||
tvbparse_action_t after_cb){
|
||||
tvbparse_wanted_t* w = g_malloc0(sizeof(tvbparse_wanted_t));
|
||||
tvbparse_wanted_t* w = (tvbparse_wanted_t *)g_malloc0(sizeof(tvbparse_wanted_t));
|
||||
|
||||
w->condition = cond_not_chars;
|
||||
w->id = id;
|
||||
|
@ -382,7 +382,7 @@ tvbparse_wanted_t* tvbparse_string(const int id,
|
|||
const void* data,
|
||||
tvbparse_action_t before_cb,
|
||||
tvbparse_action_t after_cb) {
|
||||
tvbparse_wanted_t* w = g_malloc0(sizeof(tvbparse_wanted_t));
|
||||
tvbparse_wanted_t* w = (tvbparse_wanted_t *)g_malloc0(sizeof(tvbparse_wanted_t));
|
||||
|
||||
w->condition = cond_string;
|
||||
w->id = id;
|
||||
|
@ -421,7 +421,7 @@ tvbparse_wanted_t* tvbparse_casestring(const int id,
|
|||
const void* data,
|
||||
tvbparse_action_t before_cb,
|
||||
tvbparse_action_t after_cb) {
|
||||
tvbparse_wanted_t* w = g_malloc0(sizeof(tvbparse_wanted_t));
|
||||
tvbparse_wanted_t* w = (tvbparse_wanted_t *)g_malloc0(sizeof(tvbparse_wanted_t));
|
||||
|
||||
w->condition = cond_casestring;
|
||||
w->id = id;
|
||||
|
@ -444,18 +444,18 @@ static int cond_one_of(tvbparse_t* tt, const int offset, const tvbparse_wanted_t
|
|||
return -1;
|
||||
|
||||
for(i=0; i < wanted->control.elems->len; i++) {
|
||||
tvbparse_wanted_t* w = g_ptr_array_index(wanted->control.elems,i);
|
||||
tvbparse_elem_t* new = NULL;
|
||||
tvbparse_wanted_t* w = (tvbparse_wanted_t *)g_ptr_array_index(wanted->control.elems,i);
|
||||
tvbparse_elem_t* new_elem = NULL;
|
||||
int curr_len;
|
||||
|
||||
if ( offset + w->len > tt->end_offset )
|
||||
continue;
|
||||
|
||||
curr_len = w->condition(tt, offset, w, &new);
|
||||
curr_len = w->condition(tt, offset, w, &new_elem);
|
||||
|
||||
if (curr_len >= 0) {
|
||||
*tok = new_tok(tt, wanted->id, new->offset, new->len, wanted);
|
||||
(*tok)->sub = new;
|
||||
*tok = new_tok(tt, wanted->id, new_elem->offset, new_elem->len, wanted);
|
||||
(*tok)->sub = new_elem;
|
||||
#ifdef TVBPARSE_DEBUG
|
||||
if (TVBPARSE_DEBUG & TVBPARSE_DEBUG_ONEOF) g_warning("cond_one_of: GOT len=%i",curr_len);
|
||||
#endif
|
||||
|
@ -471,7 +471,7 @@ tvbparse_wanted_t* tvbparse_set_oneof(const int id,
|
|||
tvbparse_action_t before_cb,
|
||||
tvbparse_action_t after_cb,
|
||||
...) {
|
||||
tvbparse_wanted_t* w = g_malloc0(sizeof(tvbparse_wanted_t));
|
||||
tvbparse_wanted_t* w = (tvbparse_wanted_t *)g_malloc0(sizeof(tvbparse_wanted_t));
|
||||
tvbparse_t* el;
|
||||
va_list ap;
|
||||
|
||||
|
@ -520,7 +520,7 @@ static int cond_hash(tvbparse_t* tt, const int offset, const tvbparse_wanted_t*
|
|||
if (TVBPARSE_DEBUG & TVBPARSE_DEBUG_HASH) g_warning("cond_hash: got key='%s'",key);
|
||||
#endif
|
||||
|
||||
if ((value_wanted = g_hash_table_lookup(wanted->control.hash.table,key))) {
|
||||
if ((value_wanted = (tvbparse_wanted_t *)g_hash_table_lookup(wanted->control.hash.table,key))) {
|
||||
value_len = value_wanted->condition(tt, offset + key_len, value_wanted, &value_elem);
|
||||
} else if (wanted->control.hash.other) {
|
||||
value_len = wanted->control.hash.other->condition(tt, offset+key_len, wanted->control.hash.other, &value_elem);
|
||||
|
@ -551,7 +551,7 @@ tvbparse_wanted_t* tvbparse_hashed(const int id,
|
|||
tvbparse_wanted_t* key,
|
||||
tvbparse_wanted_t* other,
|
||||
...) {
|
||||
tvbparse_wanted_t* w = g_malloc0(sizeof(tvbparse_wanted_t));
|
||||
tvbparse_wanted_t* w = (tvbparse_wanted_t *)g_malloc0(sizeof(tvbparse_wanted_t));
|
||||
gchar* name;
|
||||
tvbparse_wanted_t* el;
|
||||
va_list ap;
|
||||
|
@ -605,24 +605,24 @@ static int cond_seq(tvbparse_t* tt, int offset, const tvbparse_wanted_t * wanted
|
|||
#endif
|
||||
|
||||
for(i=0; i < wanted->control.elems->len; i++) {
|
||||
tvbparse_wanted_t* w = g_ptr_array_index(wanted->control.elems,i);
|
||||
tvbparse_elem_t* new = NULL;
|
||||
tvbparse_wanted_t* w = (tvbparse_wanted_t *)g_ptr_array_index(wanted->control.elems,i);
|
||||
tvbparse_elem_t* new_elem = NULL;
|
||||
|
||||
if ( offset + w->len > tt->end_offset )
|
||||
return -1;
|
||||
|
||||
|
||||
len = w->condition(tt, offset, w, &new);
|
||||
len = w->condition(tt, offset, w, &new_elem);
|
||||
|
||||
if (len >= 0) {
|
||||
if (ret_tok) {
|
||||
ret_tok->len = (new->offset - ret_tok->offset) + new->len;
|
||||
ret_tok->sub->last->next = new;
|
||||
ret_tok->sub->last = new;
|
||||
ret_tok->len = (new_elem->offset - ret_tok->offset) + new_elem->len;
|
||||
ret_tok->sub->last->next = new_elem;
|
||||
ret_tok->sub->last = new_elem;
|
||||
} else {
|
||||
ret_tok = new_tok(tt, wanted->id, new->offset, new->len, wanted);
|
||||
ret_tok->sub = new;
|
||||
new->last = new;
|
||||
ret_tok = new_tok(tt, wanted->id, new_elem->offset, new_elem->len, wanted);
|
||||
ret_tok->sub = new_elem;
|
||||
new_elem->last = new_elem;
|
||||
}
|
||||
} else {
|
||||
return -1;
|
||||
|
@ -647,7 +647,7 @@ tvbparse_wanted_t* tvbparse_set_seq(const int id,
|
|||
tvbparse_action_t before_cb,
|
||||
tvbparse_action_t after_cb,
|
||||
...) {
|
||||
tvbparse_wanted_t* w = g_malloc0(sizeof(tvbparse_wanted_t));
|
||||
tvbparse_wanted_t* w = (tvbparse_wanted_t *)g_malloc0(sizeof(tvbparse_wanted_t));
|
||||
tvbparse_wanted_t* el = NULL;
|
||||
va_list ap;
|
||||
|
||||
|
@ -684,27 +684,27 @@ static int cond_some(tvbparse_t* tt, int offset, const tvbparse_wanted_t * wante
|
|||
}
|
||||
|
||||
while (got_so_far < wanted->max) {
|
||||
tvbparse_elem_t* new = NULL;
|
||||
tvbparse_elem_t* new_elem = NULL;
|
||||
int consumed;
|
||||
|
||||
if ( offset > tt->end_offset )
|
||||
return -1;
|
||||
|
||||
consumed = wanted->control.subelem->condition(tt, offset, wanted->control.subelem, &new);
|
||||
consumed = wanted->control.subelem->condition(tt, offset, wanted->control.subelem, &new_elem);
|
||||
|
||||
if(consumed >= 0) {
|
||||
if (ret_tok) {
|
||||
ret_tok->len = (new->offset - ret_tok->offset) + new->len;
|
||||
ret_tok->len = (new_elem->offset - ret_tok->offset) + new_elem->len;
|
||||
|
||||
if (ret_tok->sub) {
|
||||
ret_tok->sub->last->next = new;
|
||||
ret_tok->sub->last = new;
|
||||
ret_tok->sub->last->next = new_elem;
|
||||
ret_tok->sub->last = new_elem;
|
||||
} else {
|
||||
ret_tok->sub = new;
|
||||
ret_tok->sub = new_elem;
|
||||
}
|
||||
} else {
|
||||
ret_tok = new_tok(tt, wanted->id, new->offset, new->len, wanted);
|
||||
ret_tok->sub = new;
|
||||
ret_tok = new_tok(tt, wanted->id, new_elem->offset, new_elem->len, wanted);
|
||||
ret_tok->sub = new_elem;
|
||||
}
|
||||
} else {
|
||||
break;
|
||||
|
@ -737,7 +737,7 @@ tvbparse_wanted_t* tvbparse_some(const int id,
|
|||
tvbparse_action_t after_cb,
|
||||
const tvbparse_wanted_t* el) {
|
||||
|
||||
tvbparse_wanted_t* w = g_malloc0(sizeof(tvbparse_wanted_t));
|
||||
tvbparse_wanted_t* w = (tvbparse_wanted_t *)g_malloc0(sizeof(tvbparse_wanted_t));
|
||||
|
||||
g_assert(from <= to);
|
||||
|
||||
|
@ -755,7 +755,7 @@ tvbparse_wanted_t* tvbparse_some(const int id,
|
|||
|
||||
|
||||
static int cond_until(tvbparse_t* tt, const int offset, const tvbparse_wanted_t * wanted, tvbparse_elem_t** tok) {
|
||||
tvbparse_elem_t* new = NULL;
|
||||
tvbparse_elem_t* new_elem = NULL;
|
||||
int len = 0;
|
||||
int target_offset = offset;
|
||||
#ifdef TVBPARSE_DEBUG
|
||||
|
@ -766,34 +766,34 @@ static int cond_until(tvbparse_t* tt, const int offset, const tvbparse_wanted_t
|
|||
return -1;
|
||||
|
||||
do {
|
||||
len = wanted->control.until.subelem->condition(tt, target_offset++, wanted->control.until.subelem, &new);
|
||||
len = wanted->control.until.subelem->condition(tt, target_offset++, wanted->control.until.subelem, &new_elem);
|
||||
} while(len < 0 && target_offset+1 < tt->end_offset);
|
||||
|
||||
if (len >= 0) {
|
||||
|
||||
new->id = wanted->id;
|
||||
new->next = NULL;
|
||||
new->last = NULL;
|
||||
new->wanted = wanted;
|
||||
new->offset = offset;
|
||||
new_elem->id = wanted->id;
|
||||
new_elem->next = NULL;
|
||||
new_elem->last = NULL;
|
||||
new_elem->wanted = wanted;
|
||||
new_elem->offset = offset;
|
||||
|
||||
(*tok) = new;
|
||||
(*tok) = new_elem;
|
||||
|
||||
switch (wanted->control.until.mode) {
|
||||
case TP_UNTIL_INCLUDE:
|
||||
new->len = target_offset - offset - 1 + len;
|
||||
new_elem->len = target_offset - offset - 1 + len;
|
||||
#ifdef TVBPARSE_DEBUG
|
||||
if (TVBPARSE_DEBUG & TVBPARSE_DEBUG_UNTIL) g_warning("cond_until: GOT len=%i",target_offset - offset -1 + len);
|
||||
#endif
|
||||
return target_offset - offset -1 + len;
|
||||
case TP_UNTIL_SPEND:
|
||||
new->len = target_offset - offset - 1;
|
||||
new_elem->len = target_offset - offset - 1;
|
||||
#ifdef TVBPARSE_DEBUG
|
||||
if (TVBPARSE_DEBUG & TVBPARSE_DEBUG_UNTIL) g_warning("cond_until: GOT len=%i",target_offset - offset -1 + len);
|
||||
#endif
|
||||
return target_offset - offset - 1 + len;
|
||||
case TP_UNTIL_LEAVE:
|
||||
new->len = target_offset - offset - 1;
|
||||
new_elem->len = target_offset - offset - 1;
|
||||
#ifdef TVBPARSE_DEBUG
|
||||
if (TVBPARSE_DEBUG & TVBPARSE_DEBUG_UNTIL) g_warning("cond_until: GOT len=%i",target_offset - offset -1);
|
||||
#endif
|
||||
|
@ -814,7 +814,7 @@ tvbparse_wanted_t* tvbparse_until(const int id,
|
|||
tvbparse_action_t after_cb,
|
||||
const tvbparse_wanted_t* el,
|
||||
until_mode_t until_mode) {
|
||||
tvbparse_wanted_t* w = g_malloc0(sizeof(tvbparse_wanted_t));
|
||||
tvbparse_wanted_t* w = (tvbparse_wanted_t *)g_malloc0(sizeof(tvbparse_wanted_t));
|
||||
|
||||
w->condition = cond_until;
|
||||
w->control.until.mode = until_mode;
|
||||
|
@ -839,7 +839,7 @@ static int cond_handle(tvbparse_t* tt, const int offset, const tvbparse_wanted_t
|
|||
}
|
||||
|
||||
tvbparse_wanted_t* tvbparse_handle(tvbparse_wanted_t** handle) {
|
||||
tvbparse_wanted_t* w = g_malloc0(sizeof(tvbparse_wanted_t));
|
||||
tvbparse_wanted_t* w = (tvbparse_wanted_t *)g_malloc0(sizeof(tvbparse_wanted_t));
|
||||
|
||||
w->condition = cond_handle;
|
||||
w->control.handle = handle;
|
||||
|
@ -860,7 +860,7 @@ tvbparse_wanted_t* tvbparse_end_of_buffer(const int id,
|
|||
const void* data,
|
||||
tvbparse_action_t before_cb,
|
||||
tvbparse_action_t after_cb) {
|
||||
tvbparse_wanted_t* w = g_malloc0(sizeof(tvbparse_wanted_t));
|
||||
tvbparse_wanted_t* w = (tvbparse_wanted_t *)g_malloc0(sizeof(tvbparse_wanted_t));
|
||||
|
||||
w->id = id;
|
||||
w->condition = cond_end;
|
||||
|
@ -1210,7 +1210,7 @@ tvbparse_t* tvbparse_init(tvbuff_t* tvb,
|
|||
int len,
|
||||
void* data,
|
||||
const tvbparse_wanted_t* ignore) {
|
||||
tvbparse_t* tt = ep_alloc(sizeof(tvbparse_t));
|
||||
tvbparse_t* tt = (tvbparse_t *)ep_alloc(sizeof(tvbparse_t));
|
||||
|
||||
#ifdef TVBPARSE_DEBUG
|
||||
if (TVBPARSE_DEBUG & TVBPARSE_DEBUG_TT) g_warning("tvbparse_init: offset=%i len=%i",offset,len);
|
||||
|
@ -1274,7 +1274,7 @@ static void execute_callbacks(tvbparse_t* tt, tvbparse_elem_t* curr) {
|
|||
curr = curr->next;
|
||||
|
||||
while( !curr && ep_stack_peek(stack) ) {
|
||||
curr = ep_stack_pop(stack);
|
||||
curr = (tvbparse_elem_t *)ep_stack_pop(stack);
|
||||
#ifdef TVBPARSE_DEBUG
|
||||
if (TVBPARSE_DEBUG & TVBPARSE_DEBUG_CB) g_warning("execute_callbacks: AFTER: id=%i offset=%i len=%i",curr->id,curr->offset,curr->len);
|
||||
#endif
|
||||
|
@ -1392,7 +1392,7 @@ struct _elem_tree_stack_frame {
|
|||
|
||||
void tvbparse_tree_add_elem(proto_tree* tree, tvbparse_elem_t* curr) {
|
||||
ep_stack_t stack = ep_stack_new();
|
||||
struct _elem_tree_stack_frame* frame = ep_alloc(sizeof(struct _elem_tree_stack_frame));
|
||||
struct _elem_tree_stack_frame* frame = (struct _elem_tree_stack_frame *)ep_alloc(sizeof(struct _elem_tree_stack_frame));
|
||||
proto_item* pi;
|
||||
frame->tree = tree;
|
||||
frame->elem = curr;
|
||||
|
@ -1403,7 +1403,7 @@ void tvbparse_tree_add_elem(proto_tree* tree, tvbparse_elem_t* curr) {
|
|||
if(curr->sub) {
|
||||
frame->elem = curr;
|
||||
ep_stack_push(stack,frame);
|
||||
frame = ep_alloc(sizeof(struct _elem_tree_stack_frame));
|
||||
frame = (struct _elem_tree_stack_frame *)ep_alloc(sizeof(struct _elem_tree_stack_frame));
|
||||
frame->tree = proto_item_add_subtree(pi,0);
|
||||
curr = curr->sub;
|
||||
continue;
|
||||
|
@ -1412,7 +1412,7 @@ void tvbparse_tree_add_elem(proto_tree* tree, tvbparse_elem_t* curr) {
|
|||
curr = curr->next;
|
||||
|
||||
while( !curr && ep_stack_peek(stack) ) {
|
||||
frame = ep_stack_pop(stack);
|
||||
frame = (struct _elem_tree_stack_frame *)ep_stack_pop(stack);
|
||||
curr = frame->elem->next;
|
||||
}
|
||||
|
||||
|
|
|
@ -547,7 +547,7 @@ tvb_new_octet_aligned(tvbuff_t *tvb, guint32 bit_offset, gint32 no_of_bits)
|
|||
}
|
||||
|
||||
DISSECTOR_ASSERT(datalen>0);
|
||||
buf = ep_alloc0(datalen);
|
||||
buf = (guint8 *)ep_alloc0(datalen);
|
||||
|
||||
/* if at least one trailing byte is available, we must use the content
|
||||
* of that byte for the last shift (i.e. tvb_get_ptr() must use datalen + 1
|
||||
|
@ -650,7 +650,7 @@ tvb_composite_finalize(tvbuff_t *tvb)
|
|||
|
||||
for (slist = composite->tvbs; slist != NULL; slist = slist->next) {
|
||||
DISSECTOR_ASSERT((guint) i < num_members);
|
||||
member_tvb = slist->data;
|
||||
member_tvb = (tvbuff_t *)slist->data;
|
||||
composite->start_offsets[i] = tvb->length;
|
||||
tvb->length += member_tvb->length;
|
||||
tvb->reported_length += member_tvb->reported_length;
|
||||
|
@ -855,7 +855,7 @@ offset_from_real_beginning(const tvbuff_t *tvb, const guint counter)
|
|||
member = tvb->tvbuffs.subset.tvb;
|
||||
return offset_from_real_beginning(member, counter + tvb->tvbuffs.subset.offset);
|
||||
case TVBUFF_COMPOSITE:
|
||||
member = tvb->tvbuffs.composite.tvbs->data;
|
||||
member = (tvbuff_t *)tvb->tvbuffs.composite.tvbs->data;
|
||||
return offset_from_real_beginning(member, counter);
|
||||
}
|
||||
|
||||
|
@ -888,7 +888,7 @@ composite_ensure_contiguous_no_exception(tvbuff_t *tvb, const guint abs_offset,
|
|||
for (i = 0; i < num_members; i++) {
|
||||
if (abs_offset <= composite->end_offsets[i]) {
|
||||
slist = g_slist_nth(composite->tvbs, i);
|
||||
member_tvb = slist->data;
|
||||
member_tvb = (tvbuff_t *)slist->data;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -905,7 +905,7 @@ composite_ensure_contiguous_no_exception(tvbuff_t *tvb, const guint abs_offset,
|
|||
return ensure_contiguous_no_exception(member_tvb, member_offset, member_length, NULL);
|
||||
}
|
||||
else {
|
||||
tvb->real_data = tvb_memdup(tvb, 0, -1);
|
||||
tvb->real_data = (guint8 *)tvb_memdup(tvb, 0, -1);
|
||||
return tvb->real_data + abs_offset;
|
||||
}
|
||||
|
||||
|
@ -1035,7 +1035,7 @@ composite_memcpy(tvbuff_t *tvb, guint8* target, guint abs_offset, size_t abs_len
|
|||
for (i = 0; i < num_members; i++) {
|
||||
if (abs_offset <= composite->end_offsets[i]) {
|
||||
slist = g_slist_nth(composite->tvbs, i);
|
||||
member_tvb = slist->data;
|
||||
member_tvb = (tvbuff_t *)slist->data;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -1110,7 +1110,7 @@ tvb_memcpy(tvbuff_t *tvb, void *target, const gint offset, size_t length)
|
|||
abs_length);
|
||||
|
||||
case TVBUFF_COMPOSITE:
|
||||
return composite_memcpy(tvb, target, offset, length);
|
||||
return composite_memcpy(tvb, (guint8 *)target, offset, length);
|
||||
}
|
||||
|
||||
DISSECTOR_ASSERT_NOT_REACHED();
|
||||
|
@ -1752,7 +1752,7 @@ ep_tvb_get_bits(tvbuff_t *tvb, guint bit_offset, gint no_of_bits, gboolean lsb0)
|
|||
}
|
||||
|
||||
no_of_bytes = (no_of_bits >> 3) + ((no_of_bits & 0x7) != 0); /* ceil(no_of_bits / 8.0) */
|
||||
buf = ep_alloc(no_of_bytes);
|
||||
buf = (guint8 *)ep_alloc(no_of_bytes);
|
||||
tvb_get_bits_buf(tvb, bit_offset, no_of_bits, buf, lsb0);
|
||||
return buf;
|
||||
}
|
||||
|
@ -1905,7 +1905,7 @@ tvb_find_guint8(tvbuff_t *tvb, const gint offset, const gint maxlength, const gu
|
|||
|
||||
/* If we have real data, perform our search now. */
|
||||
if (tvb->real_data) {
|
||||
result = memchr(tvb->real_data + abs_offset, needle, limit);
|
||||
result = (const guint8 *)memchr(tvb->real_data + abs_offset, needle, limit);
|
||||
if (result == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
@ -2178,7 +2178,7 @@ tvb_fake_unicode(tvbuff_t *tvb, int offset, const int len, const gboolean little
|
|||
|
||||
/* We know we won't throw an exception, so we don't have to worry
|
||||
about leaking this buffer. */
|
||||
buffer = g_malloc(len + 1);
|
||||
buffer = (char *)g_malloc(len + 1);
|
||||
|
||||
for (i = 0; i < len; i++) {
|
||||
character = little_endian ? tvb_get_letohs(tvb, offset)
|
||||
|
@ -2214,7 +2214,7 @@ tvb_get_ephemeral_faked_unicode(tvbuff_t *tvb, int offset, const int len, const
|
|||
|
||||
/* We know we won't throw an exception, so we don't have to worry
|
||||
about leaking this buffer. */
|
||||
buffer = ep_alloc(len + 1);
|
||||
buffer = (char *)ep_alloc(len + 1);
|
||||
|
||||
for (i = 0; i < len; i++) {
|
||||
character = little_endian ? tvb_get_letohs(tvb, offset)
|
||||
|
@ -2332,7 +2332,7 @@ tvb_get_string(tvbuff_t *tvb, const gint offset, const gint length)
|
|||
tvb_ensure_bytes_exist(tvb, offset, length);
|
||||
|
||||
ptr = ensure_contiguous(tvb, offset, length);
|
||||
strbuf = g_malloc(length + 1);
|
||||
strbuf = (guint8 *)g_malloc(length + 1);
|
||||
if (length != 0) {
|
||||
memcpy(strbuf, ptr, length);
|
||||
}
|
||||
|
@ -2451,7 +2451,7 @@ tvb_get_ephemeral_string_enc(tvbuff_t *tvb, const gint offset,
|
|||
* XXX - multiple "dialects" of EBCDIC?
|
||||
*/
|
||||
tvb_ensure_bytes_exist(tvb, offset, length); /* make sure length = -1 fails */
|
||||
strbuf = ep_alloc(length + 1);
|
||||
strbuf = (guint8 *)ep_alloc(length + 1);
|
||||
if (length != 0) {
|
||||
ptr = ensure_contiguous(tvb, offset, length);
|
||||
memcpy(strbuf, ptr, length);
|
||||
|
@ -2469,7 +2469,7 @@ tvb_get_ephemeral_string(tvbuff_t *tvb, const gint offset, const gint length)
|
|||
guint8 *strbuf;
|
||||
|
||||
tvb_ensure_bytes_exist(tvb, offset, length); /* make sure length = -1 fails */
|
||||
strbuf = ep_alloc(length + 1);
|
||||
strbuf = (guint8 *)ep_alloc(length + 1);
|
||||
tvb_memcpy(tvb, strbuf, offset, length);
|
||||
strbuf[length] = '\0';
|
||||
return strbuf;
|
||||
|
@ -2539,7 +2539,7 @@ tvb_get_seasonal_string(tvbuff_t *tvb, const gint offset, const gint length)
|
|||
tvb_ensure_bytes_exist(tvb, offset, length);
|
||||
|
||||
ptr = ensure_contiguous(tvb, offset, length);
|
||||
strbuf = se_alloc(length + 1);
|
||||
strbuf = (guint8 *)se_alloc(length + 1);
|
||||
if (length != 0) {
|
||||
memcpy(strbuf, ptr, length);
|
||||
}
|
||||
|
@ -2563,7 +2563,7 @@ tvb_get_stringz_enc(tvbuff_t *tvb, const gint offset, gint *lengthp, const guint
|
|||
guint8 *strptr;
|
||||
|
||||
size = tvb_strsize(tvb, offset);
|
||||
strptr = g_malloc(size);
|
||||
strptr = (guint8 *)g_malloc(size);
|
||||
tvb_memcpy(tvb, strptr, offset, size);
|
||||
if ((encoding & ENC_CHARENCODING_MASK) == ENC_EBCDIC)
|
||||
EBCDIC_to_ASCII(strptr, size);
|
||||
|
@ -2679,7 +2679,7 @@ tvb_get_ephemeral_stringz_enc(tvbuff_t *tvb, const gint offset, gint *lengthp, c
|
|||
* XXX - multiple "dialects" of EBCDIC?
|
||||
*/
|
||||
size = tvb_strsize(tvb, offset);
|
||||
strptr = ep_alloc(size);
|
||||
strptr = (guint8 *)ep_alloc(size);
|
||||
tvb_memcpy(tvb, strptr, offset, size);
|
||||
EBCDIC_to_ASCII(strptr, size);
|
||||
if (lengthp)
|
||||
|
@ -2697,7 +2697,7 @@ tvb_get_ephemeral_stringz(tvbuff_t *tvb, const gint offset, gint *lengthp)
|
|||
guint8 *strptr;
|
||||
|
||||
size = tvb_strsize(tvb, offset);
|
||||
strptr = ep_alloc(size);
|
||||
strptr = (guint8 *)ep_alloc(size);
|
||||
tvb_memcpy(tvb, strptr, offset, size);
|
||||
if (lengthp)
|
||||
*lengthp = size;
|
||||
|
@ -2767,7 +2767,7 @@ tvb_get_seasonal_stringz(tvbuff_t *tvb, const gint offset, gint *lengthp)
|
|||
guint8 *strptr;
|
||||
|
||||
size = tvb_strsize(tvb, offset);
|
||||
strptr = se_alloc(size);
|
||||
strptr = (guint8 *)se_alloc(size);
|
||||
tvb_memcpy(tvb, strptr, offset, size);
|
||||
if (lengthp)
|
||||
*lengthp = size;
|
||||
|
@ -3268,7 +3268,7 @@ tvb_bcd_dig_to_ep_str(tvbuff_t *tvb, const gint offset, const gint len, dgt_set_
|
|||
} else {
|
||||
length = offset + len;
|
||||
}
|
||||
digit_str = ep_alloc((length - offset)*2+1);
|
||||
digit_str = (char *)ep_alloc((length - offset)*2+1);
|
||||
|
||||
while (t_offset < length) {
|
||||
|
||||
|
@ -3374,7 +3374,7 @@ tvb_uncompress(tvbuff_t *tvb, const int offset, int comprlen)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
compr = tvb_memdup(tvb, offset, comprlen);
|
||||
compr = (guint8 *)tvb_memdup(tvb, offset, comprlen);
|
||||
|
||||
if (!compr)
|
||||
return NULL;
|
||||
|
@ -3396,7 +3396,7 @@ tvb_uncompress(tvbuff_t *tvb, const int offset, int comprlen)
|
|||
strm->next_in = next;
|
||||
strm->avail_in = comprlen;
|
||||
|
||||
strmbuf = g_malloc0(bufsiz);
|
||||
strmbuf = (Bytef *)g_malloc0(bufsiz);
|
||||
strm->next_out = strmbuf;
|
||||
strm->avail_out = bufsiz;
|
||||
|
||||
|
@ -3433,11 +3433,11 @@ tvb_uncompress(tvbuff_t *tvb, const int offset, int comprlen)
|
|||
* when uncompr is NULL logic below doesn't create tvb
|
||||
* which is later interpreted as decompression failed.
|
||||
*/
|
||||
uncompr = (bytes_pass || err != Z_STREAM_END) ?
|
||||
uncompr = (guint8 *)((bytes_pass || err != Z_STREAM_END) ?
|
||||
g_memdup(strmbuf, bytes_pass) :
|
||||
g_strdup("");
|
||||
g_strdup(""));
|
||||
} else {
|
||||
guint8 *new_data = g_malloc0(bytes_out + bytes_pass);
|
||||
guint8 *new_data = (guint8 *)g_malloc0(bytes_out + bytes_pass);
|
||||
|
||||
memcpy(new_data, uncompr, bytes_out);
|
||||
memcpy(new_data + bytes_out, strmbuf, bytes_pass);
|
||||
|
|
Loading…
Reference in New Issue