aboutsummaryrefslogtreecommitdiffstats
path: root/epan/tvbuff.h
diff options
context:
space:
mode:
authorPascal Quantin <pascal.quantin@gmail.com>2013-09-22 15:50:55 +0000
committerPascal Quantin <pascal.quantin@gmail.com>2013-09-22 15:50:55 +0000
commita0c53ffaa1bb46d8c9db2ec739401aa411c9790e (patch)
tree56a11c9e0910032ad43476462dd2c95ed65e5cc1 /epan/tvbuff.h
parentc4a608a94071f4a23eaf16fd3ab9545e26309f76 (diff)
emem -> wmem conversion:
- ep_tvb_get_bits() -> wmem_packet_tvb_get_bits() - tvb_g_memdup()/ep_tvb_memdup() -> tvb_memdup() - tvb_fake_unicode()/tvb_get_ephemeral_faked_unicode() -> tvb_get_faked_unicode() - tvb_get_g_string()/tvb_get_ephemeral_string()/tvb_get_seasonal_string() -> tvb_get_string() - tvb_get_g_unicode_string()/tvb_get_ephemeral_unicode_string() -> tvb_get_unicode_string() - tvb_get_ephemeral_string_enc() -> tvb_get_string_enc() - update docs accordingly svn path=/trunk/; revision=52172
Diffstat (limited to 'epan/tvbuff.h')
-rw-r--r--epan/tvbuff.h68
1 files changed, 24 insertions, 44 deletions
diff --git a/epan/tvbuff.h b/epan/tvbuff.h
index 4bdfc5d8f5..90d2d10806 100644
--- a/epan/tvbuff.h
+++ b/epan/tvbuff.h
@@ -38,6 +38,7 @@
#include <glib.h>
#include <epan/ipv6-utils.h>
#include <epan/guid-utils.h>
+#include <epan/wmem/wmem.h>
#include "exceptions.h"
#ifdef __cplusplus
@@ -327,7 +328,7 @@ WS_DLL_PUBLIC guint32 tvb_get_bits(tvbuff_t *tvb, const guint bit_offset, const
WS_DLL_PUBLIC
void tvb_get_bits_buf(tvbuff_t *tvb, guint bit_offset, gint no_of_bits, guint8 *buf, gboolean lsb0);
WS_DLL_PUBLIC
-guint8 *ep_tvb_get_bits(tvbuff_t *tvb, guint bit_offset, gint no_of_bits, gboolean lsb0);
+guint8 *wmem_packet_tvb_get_bits(tvbuff_t *tvb, guint bit_offset, gint no_of_bits, gboolean lsb0);
/** Returns target for convenience. Does not suffer from possible
* expense of tvb_get_ptr(), since this routine is smart enough
@@ -337,15 +338,11 @@ guint8 *ep_tvb_get_bits(tvbuff_t *tvb, guint bit_offset, gint no_of_bits, gboole
* target memory. */
WS_DLL_PUBLIC void* tvb_memcpy(tvbuff_t*, void* target, const gint offset, size_t length);
-/** It is the user's responsibility to g_free() the memory allocated by
- * tvb_g_memdup(). Calls tvb_memcpy() */
-WS_DLL_PUBLIC void* tvb_g_memdup(tvbuff_t*, const gint offset, size_t length);
-
-/* Same as above but the buffer returned from this function does not have to
-* be freed. It will be automatically freed after the packet is dissected.
-* Buffers allocated by this function are NOT persistent.
-*/
-WS_DLL_PUBLIC void* ep_tvb_memdup(tvbuff_t *tvb, const gint offset, size_t length);
+/** If scope is set to NULL it is the user's responsibility to g_free()
+ * the memory allocated by tvb_memdup(). Otherwise memory is
+ * automatically freed when the scope lifetime is reached.
+ * Calls tvb_memcpy() */
+WS_DLL_PUBLIC void* tvb_memdup(wmem_allocator_t *scope, tvbuff_t *tvb, const gint offset, size_t length);
/** WARNING! This function is possibly expensive, temporarily allocating
* another copy of the packet data. Furthermore, it's dangerous because once
@@ -419,19 +416,13 @@ WS_DLL_PUBLIC gint tvb_strnlen(tvbuff_t*, const gint offset, const guint maxleng
* of guint16's to convert from Unicode.
*
* XXX - These functions have been superceded by tvb_get_unicode_string()
- * and tvb_get_ephemeral_unicode_string()
- *
- * tvb_fake_unicode() returns a buffer allocated by g_malloc() and must
- * be g_free() by the caller.
- * tvb_get_ephemeral_faked_unicode() returns a buffer that does not need
- * to be explicitely freed. Instead this buffer is
- * automatically freed when wireshark starts dissecting
- * the next packet.
+ *
+ * If scope is set to NULL, returned buffer is allocated by g_malloc()
+ * and must be g_free by the caller. Otherwise memory is automatically
+ * freed when the scope lifetime is reached.
*/
-WS_DLL_PUBLIC char *tvb_fake_unicode(tvbuff_t *tvb, int offset, const int len,
- const gboolean little_endian);
-WS_DLL_PUBLIC char *tvb_get_ephemeral_faked_unicode(tvbuff_t *tvb, int offset, const int len,
- const gboolean little_endian);
+WS_DLL_PUBLIC char *tvb_get_faked_unicode(wmem_allocator_t *scope, tvbuff_t *tvb,
+ int offset, const int len, const gboolean little_endian);
/**
* Format the data in the tvb from offset for size ...
@@ -465,33 +456,22 @@ extern gchar *tvb_format_stringzpad_wsp(tvbuff_t *tvb, const gint offset, const
*
* Throws an exception if the tvbuff ends before the string does.
*
- * tvb_get_string() returns a string allocated by g_malloc() and therefore
- * MUST be g_free() by the caller in order not to leak
- * memory.
- *
- * tvb_get_unicode_string() Unicode (UTF-16) version of above
- *
- * tvb_get_ephemeral_string() returns a string that does not need to be freed,
- * instead it will automatically be freed once the next
- * packet is dissected.
+ * tvb_get_string() returns a string allocated.
*
- * tvb_get_ephemeral_string_enc() takes a string encoding as well, and
- * converts to UTF-8 from the encoding (only UTF-8 and
- * EBCDIC supported)
+ * tvb_get_unicode_string() Unicode (UTF-16) version of above.
*
- * tvb_get_ephemeral_unicode_string() Unicode (UTF-16) version of above
+ * tvb_get_string_enc() takes a string encoding as well, and converts to UTF-8
+ * from the encoding (only UTF-8 and EBCDIC supported).
*
- * tvb_get_seasonal_string() returns a string that does not need to be freed,
- * instead it will automatically be freed when a new capture
- * or file is opened.
+ * If scope is set to NULL it is the user's responsibility to g_free()
+ * the memory allocated by tvb_memdup(). Otherwise memory is
+ * automatically freed when the scope lifetime is reached.
*/
-WS_DLL_PUBLIC guint8 *tvb_get_g_string(tvbuff_t *tvb, const gint offset, const gint length);
-WS_DLL_PUBLIC gchar *tvb_get_g_unicode_string(tvbuff_t *tvb, const gint offset, gint length, const guint encoding);
-WS_DLL_PUBLIC guint8 *tvb_get_ephemeral_string(tvbuff_t *tvb, const gint offset, const gint length);
-WS_DLL_PUBLIC guint8 *tvb_get_ephemeral_string_enc(tvbuff_t *tvb, const gint offset,
+WS_DLL_PUBLIC guint8 *tvb_get_string(wmem_allocator_t *scope, tvbuff_t *tvb, const gint offset, const gint length);
+WS_DLL_PUBLIC gchar *tvb_get_unicode_string(wmem_allocator_t *scope, tvbuff_t *tvb, const gint offset, gint length,
+ const guint encoding);
+WS_DLL_PUBLIC guint8 *tvb_get_string_enc(wmem_allocator_t *scope, tvbuff_t *tvb, const gint offset,
const gint length, const guint encoding);
-extern gchar *tvb_get_ephemeral_unicode_string(tvbuff_t *tvb, const gint offset, gint length, const guint encoding);
-extern guint8 *tvb_get_seasonal_string(tvbuff_t *tvb, const gint offset, const gint length);
/**