Wireshark  4.3.0
The Wireshark network protocol analyzer
Macros | Functions
String Utilities

Macros

#define ws_strdup(src)   wmem_strdup(NULL, src)
 
#define ws_strndup(src, len)   wmem_strndup(NULL, src, len)
 
#define ws_strdup_printf(...)   wmem_strdup_printf(NULL, __VA_ARGS__)
 
#define ws_strdup_vprintf(fmt, ap)   wmem_strdup_vprintf(NULL, fmt, ap)
 

Functions

WS_DLL_PUBLIC void * wmem_memdup (wmem_allocator_t *allocator, const void *source, const size_t size) G_GNUC_MALLOC
 
WS_DLL_PUBLIC int wmem_compare_int (gconstpointer a, gconstpointer b)
 
WS_DLL_PUBLIC int wmem_compare_uint (gconstpointer a, gconstpointer b)
 
WS_DLL_PUBLIC char * wmem_strdup (wmem_allocator_t *allocator, const char *src) G_GNUC_MALLOC
 
WS_DLL_PUBLIC char * wmem_strndup (wmem_allocator_t *allocator, const char *src, const size_t len) G_GNUC_MALLOC
 
WS_DLL_PUBLIC char * wmem_strdup_printf (wmem_allocator_t *allocator, const char *fmt,...) G_GNUC_MALLOC G_GNUC_PRINTF(2
 
WS_DLL_PUBLIC char * wmem_strdup_vprintf (wmem_allocator_t *allocator, const char *fmt, va_list ap) G_GNUC_MALLOC
 
WS_DLL_PUBLIC const uint8_t * ws_memmem (const void *haystack, size_t haystack_len, const void *needle, size_t needle_len)
 

Detailed Description

A collection of misc. utility functions for wmem.

A collection of utility function for operating on C strings with wmem.

Function Documentation

◆ wmem_compare_int()

WS_DLL_PUBLIC int wmem_compare_int ( gconstpointer  a,
gconstpointer  b 
)

Generic GCompareFunc implementations to compare signed/unsigned integer

◆ wmem_memdup()

WS_DLL_PUBLIC void* wmem_memdup ( wmem_allocator_t allocator,
const void *  source,
const size_t  size 
)

Copies a block of memory.

Parameters
allocatorThe allocator object to use to allocate memory to copy into.
sourceThe pointer to the memory block to copy.
sizeThe amount of memory to copy.
Returns
The location of the memory copy or NULL if size is 0.

◆ ws_memmem()

WS_DLL_PUBLIC const uint8_t* ws_memmem ( const void *  haystack,
size_t  haystack_len,
const void *  needle,
size_t  needle_len 
)

Return the first occurrence of needle in haystack.

Parameters
haystackThe data to search
haystack_lenThe length of the search data
needleThe string to look for
needle_lenThe length of the search string
Returns
A pointer to the first occurrence of "needle" in "haystack". If "needle" isn't found or is NULL, NULL is returned. If "needle_len" is 0, a pointer to "haystack" is returned.