diff options
author | Jeff Morriss <jeff.morriss@ulticom.com> | 2011-01-12 02:25:08 +0000 |
---|---|---|
committer | Jeff Morriss <jeff.morriss@ulticom.com> | 2011-01-12 02:25:08 +0000 |
commit | 0c4e881911efcf0ddc1278a0ed2bd100d8d06c43 (patch) | |
tree | ccf27b3ad65b72ef7318a4bcd3f1d78bb663b019 /doc/README.developer | |
parent | 1c5d75288c8f5b83659f4f5969ca0ef4a2cde2f9 (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 'doc/README.developer')
-rw-r--r-- | doc/README.developer | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/doc/README.developer b/doc/README.developer index 4109f166db..56e3424466 100644 --- a/doc/README.developer +++ b/doc/README.developer @@ -1277,20 +1277,26 @@ free() this buffer, it will happen automatically once the a new capture or file is opened. guint8 *tvb_get_stringz(tvbuff_t *tvb, gint offset, gint *lengthp); +const guint8 *tvb_get_const stringz(tvbuff_t *tvb, gint offset, gint *lengthp); guint8 *tvb_get_ephemeral_stringz(tvbuff_t *tvb, gint offset, gint *lengthp); gchar *tvb_get_ephemeral_unicode_stringz(tvbuff_t *tvb, const gint offset, gint *lengthp, const guint encoding); guint8 *tvb_get_seasonal_stringz(tvbuff_t *tvb, gint offset, gint *lengthp); -Returns a null-terminated buffer, allocated with "g_malloc()", -containing data from the specified tvbuff, starting at the -specified offset, and containing all characters from the tvbuff up to -and including a terminating null character in the tvbuff. "*lengthp" -will be set to the length of the string, including the terminating null. +Returns a null-terminated buffer containing data from the specified tvbuff, +starting at the specified offset, and containing all characters from the +tvbuff up to and including a terminating null character in the tvbuff. +"*lengthp" will be set to the length of the string, including the terminating +null. tvb_get_stringz() returns a buffer allocated by g_malloc() so you must g_free() it when you are finished with the string. Failure to g_free() this buffer will lead to memory leaks. +tvb_get_const_stringz() returns a pointer to the (const) string in the tvbuff. +You do not need to free() this buffer, it will happen automatically once the +next packet is dissected. This function is slightly more efficient than the +others because it does not allocate memory and copy the string. + tvb_get_ephemeral_stringz() returns a buffer allocated from a special heap with a lifetime until the next packet is dissected. You do not need to free() this buffer, it will happen automatically once the next packet is |