2 * Definitions for the Wireshark Memory Manager String Utilities
3 * Copyright 2012, Evan Huus <eapache@gmail.com>
5 * Wireshark - Network traffic analyzer
6 * By Gerald Combs <gerald@wireshark.org>
7 * Copyright 1998 Gerald Combs
9 * SPDX-License-Identifier: GPL-2.0-or-later
12 #ifndef __WMEM_STRUTL_H__
13 #define __WMEM_STRUTL_H__
17 #include "wmem_core.h"
21 #endif /* __cplusplus */
25 * @defgroup wmem-strutl String Utilities
27 * A collection of utility function for operating on C strings with wmem.
34 wmem_strdup(wmem_allocator_t
*allocator
, const char *src
)
37 #define ws_strdup(src) wmem_strdup(NULL, src)
41 wmem_strndup(wmem_allocator_t
*allocator
, const char *src
, const size_t len
)
44 #define ws_strndup(src, len) wmem_strndup(NULL, src, len)
48 wmem_strdup_printf(wmem_allocator_t
*allocator
, const char *fmt
, ...)
49 G_GNUC_MALLOC
G_GNUC_PRINTF(2, 3);
51 #define ws_strdup_printf(...) wmem_strdup_printf(NULL, __VA_ARGS__)
55 wmem_strdup_vprintf(wmem_allocator_t
*allocator
, const char *fmt
, va_list ap
)
58 #define ws_strdup_vprintf(fmt, ap) wmem_strdup_vprintf(NULL, fmt, ap)
61 * Return the first occurrence of needle in haystack.
63 * @param haystack The data to search
64 * @param haystack_len The length of the search data
65 * @param needle The string to look for
66 * @param needle_len The length of the search string
67 * @return A pointer to the first occurrence of "needle" in
68 * "haystack". If "needle" isn't found or is NULL, NULL is returned.
69 * If "needle_len" is 0, a pointer to "haystack" is returned.
72 const uint8_t *ws_memmem(const void *haystack
, size_t haystack_len
,
73 const void *needle
, size_t needle_len
);
80 #endif /* __cplusplus */
82 #endif /* __WMEM_STRUTL_H__ */
85 * Editor modelines - https://www.wireshark.org/tools/modelines.html
90 * indent-tabs-mode: nil
93 * vi: set shiftwidth=4 tabstop=8 expandtab:
94 * :indentSize=4:tabSize=8:noTabs=true: