/* If scope is NULL, memory is allocated with g_malloc() and user must explicitly free it with g_free(). If scope is not NULL, memory is allocated with the corresponding pool lifetime.  */
void* tvb_memdup(wmem_allocator_t *scope, tvbuff_t *tvb, const gint offset, size_t length)
/* If scope is NULL, memory is allocated with g_malloc() and user must explicitly free it with g_free(). If scope is not NULL, memory is allocated with the corresponding pool lifetime.  */
void* tvb_memdup(wmem_allocator_t *scope, tvbuff_t *tvb, const gint offset, size_t length)
{
	guint  abs_offset = 0, abs_length = 0;
	void  *duped;
	DISSECTOR_ASSERT(tvb && tvb->initialized);
	check_offset_length(tvb, offset, (gint) length, &abs_offset, &abs_length);
	duped = wmem_alloc(scope, abs_length);
	return tvb_memcpy(tvb, duped, abs_offset, abs_length);
}