Add to new functions from the optimization patch:

tvb_child_uncompress()
tvb_new_child_real_data()

svn path=/trunk/; revision=27924
This commit is contained in:
Anders Broman 2009-04-01 16:22:51 +00:00
parent 87c4184e91
commit 4ba5d2f92b
2 changed files with 30 additions and 0 deletions

View File

@ -299,6 +299,17 @@ tvb_new_real_data(const guint8* data, guint length, gint reported_length)
return tvb;
}
tvbuff_t*
tvb_new_child_real_data(tvbuff_t *parent, const guint8* data, guint length, gint reported_length)
{
tvbuff_t *tvb = tvb_new_real_data(data, length, reported_length);
if (tvb) {
tvb_set_child_real_data_tvbuff (parent, tvb);
}
return tvb;
}
/* Computes the absolute offset and length based on a possibly-negative offset
* and a length that is possible -1 (which means "to the end of the data").
* Returns TRUE/FALSE indicating whether the offset is in bounds or
@ -3046,3 +3057,12 @@ tvb_uncompress(tvbuff_t *tvb _U_, int offset _U_, int comprlen _U_)
}
#endif
tvbuff_t* tvb_child_uncompress(tvbuff_t *parent _U_, tvbuff_t *tvb, int offset, int comprlen)
{
tvbuff_t *new_tvb = tvb_uncompress(tvb, offset, comprlen);
if (new_tvb)
tvb_set_child_real_data_tvbuff (parent, new_tvb);
return new_tvb;
}

View File

@ -208,6 +208,9 @@ extern void tvb_set_free_cb(tvbuff_t*, tvbuff_free_cb_t);
* the tvbuff routines knowledgable of this fact. */
extern void tvb_set_child_real_data_tvbuff(tvbuff_t* parent, tvbuff_t* child);
extern tvbuff_t* tvb_new_child_real_data(tvbuff_t* parent, const guint8* data, guint length,
gint reported_length);
/**Sets parameters for TVBUFF_REAL_DATA. Can throw ReportedBoundsError. */
extern void tvb_set_real_data(tvbuff_t*, const guint8* data, guint length,
gint reported_length);
@ -635,6 +638,13 @@ extern gint tvb_find_tvb(tvbuff_t *haystack_tvb, tvbuff_t *needle_tvb,
*/
extern tvbuff_t* tvb_uncompress(tvbuff_t *tvb, int offset, int comprlen);
/**
* Uncompresses a zlib compressed packet inside a tvbuff at offset with
* length comprlen. Returns an uncompressed tvbuffer attached to tvb if uncompression
* succeeded or NULL if uncompression failed.
*/
extern tvbuff_t* tvb_child_uncompress(tvbuff_t *parent, tvbuff_t *tvb, int offset, int comprlen);
/************** END OF ACCESSORS ****************/
#endif /* __TVBUFF_H__ */