regen pidl all: rm epan/dissectors/pidl/*-stamp; pushd epan/dissectors/pidl/ && make...
[wireshark-sm.git] / wsutil / wmem / wmem_strutl.h
blob104a1ebadbc86271ee7cf600e5848fa99f727ecf
1 /** @file
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__
15 #include <stdarg.h>
17 #include "wmem_core.h"
19 #ifdef __cplusplus
20 extern "C" {
21 #endif /* __cplusplus */
23 /** @addtogroup wmem
24 * @{
25 * @defgroup wmem-strutl String Utilities
27 * A collection of utility function for operating on C strings with wmem.
29 * @{
32 WS_DLL_PUBLIC
33 char *
34 wmem_strdup(wmem_allocator_t *allocator, const char *src)
35 G_GNUC_MALLOC;
37 #define ws_strdup(src) wmem_strdup(NULL, src)
39 WS_DLL_PUBLIC
40 char *
41 wmem_strndup(wmem_allocator_t *allocator, const char *src, const size_t len)
42 G_GNUC_MALLOC;
44 #define ws_strndup(src, len) wmem_strndup(NULL, src, len)
46 WS_DLL_PUBLIC
47 char *
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__)
53 WS_DLL_PUBLIC
54 char *
55 wmem_strdup_vprintf(wmem_allocator_t *allocator, const char *fmt, va_list ap)
56 G_GNUC_MALLOC;
58 #define ws_strdup_vprintf(fmt, ap) wmem_strdup_vprintf(NULL, fmt, ap)
60 /**
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.
71 WS_DLL_PUBLIC
72 const uint8_t *ws_memmem(const void *haystack, size_t haystack_len,
73 const void *needle, size_t needle_len);
75 /** @}
76 * @} */
78 #ifdef __cplusplus
80 #endif /* __cplusplus */
82 #endif /* __WMEM_STRUTL_H__ */
85 * Editor modelines - https://www.wireshark.org/tools/modelines.html
87 * Local variables:
88 * c-basic-offset: 4
89 * tab-width: 8
90 * indent-tabs-mode: nil
91 * End:
93 * vi: set shiftwidth=4 tabstop=8 expandtab:
94 * :indentSize=4:tabSize=8:noTabs=true: