aboutsummaryrefslogtreecommitdiffstats
path: root/epan/tvbuff.h
diff options
context:
space:
mode:
authorJeff Morriss <jeff.morriss@ulticom.com>2011-01-12 02:25:08 +0000
committerJeff Morriss <jeff.morriss@ulticom.com>2011-01-12 02:25:08 +0000
commit0c4e881911efcf0ddc1278a0ed2bd100d8d06c43 (patch)
treeccf27b3ad65b72ef7318a4bcd3f1d78bb663b019 /epan/tvbuff.h
parent1c5d75288c8f5b83659f4f5969ca0ef4a2cde2f9 (diff)
Introduce, and start using, tvb_get_const_stringz(). This function returns a
pointer to a NULL-terminated string in the TVB. It is no safer than dissectors which call tvb_get_strsize() and then tvb_get_ptr() but it makes it clear that this usage of tvb_get_ptr() is safe. This function is slightly more efficient than tvb_get_ephemeral_stringz()--but only as long as we're not using composite TVBs. svn path=/trunk/; revision=35493
Diffstat (limited to 'epan/tvbuff.h')
-rw-r--r--epan/tvbuff.h10
1 files changed, 8 insertions, 2 deletions
diff --git a/epan/tvbuff.h b/epan/tvbuff.h
index 62189e2228..cd9d63b659 100644
--- a/epan/tvbuff.h
+++ b/epan/tvbuff.h
@@ -517,6 +517,11 @@ extern guint8 *tvb_get_seasonal_string(tvbuff_t *tvb, const gint offset, const g
* MUST be g_free() by the caller in order not to leak
* memory.
*
+ * tvb_get_const_stringz() returns a constant (unmodifiable) string that does
+ * not need to be freed, instead it will automatically be
+ * freed once the next packet is dissected. It is slightly
+ * more efficient than the other routines.
+ *
* tvb_get_ephemeral_stringz() returns a string that does not need to be freed,
* instead it will automatically be freed once the next
* packet is dissected.
@@ -528,6 +533,7 @@ extern guint8 *tvb_get_seasonal_string(tvbuff_t *tvb, const gint offset, const g
* or file is opened.
*/
extern guint8 *tvb_get_stringz(tvbuff_t *tvb, const gint offset, gint *lengthp);
+extern const guint8 *tvb_get_const_stringz(tvbuff_t *tvb, const gint offset, gint *lengthp);
extern guint8 *tvb_get_ephemeral_stringz(tvbuff_t *tvb, const gint offset, gint *lengthp);
extern gchar *tvb_get_ephemeral_unicode_stringz(tvbuff_t *tvb, const gint offset, gint *lengthp, const guint encoding);
extern guint8 *tvb_get_seasonal_stringz(tvbuff_t *tvb, const gint offset, gint *lengthp);
@@ -659,8 +665,8 @@ extern gchar *tvb_bytes_to_str(tvbuff_t *tvb, const gint offset, const gint len)
/**
* Given a tvbuff, an offset into the tvbuff, and a length that starts
* at that offset (which may be -1 for "all the way to the end of the
- * tvbuff"), fetch BCD encoded digits from a tvbuff starting from either
- * the low or high half byte, formating the digits according to an input digit set,
+ * tvbuff"), fetch BCD encoded digits from a tvbuff starting from either
+ * the low or high half byte, formating the digits according to an input digit set,
* if NUll a default digit set of 0-9 returning "?" for overdecadic digits will be used.
* A pointer to the EP allocated string will be returned.
* Note a tvbuff content of 0xf is considered a 'filler' and will end the conversion.