regen pidl all: rm epan/dissectors/pidl/*-stamp; pushd epan/dissectors/pidl/ && make...
[wireshark-sm.git] / wsutil / wmem / wmem_miscutl.c
blob6e3e2a3a991d14543b8878c971323ae1666babb1
1 /* wmem_miscutl.c
2 * Wireshark Memory Manager Misc Utilities
3 * Copyright 2013, 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 #include <string.h>
13 #include <glib.h>
15 #include "wmem_core.h"
16 #include "wmem_miscutl.h"
18 void *
19 wmem_memdup(wmem_allocator_t *allocator, const void *source, const size_t size)
21 void *dest;
23 if (!size)
24 return NULL;
26 dest = wmem_alloc(allocator, size);
27 memcpy(dest, source, size);
29 return dest;
32 int
33 wmem_compare_int(const void *a, const void *b)
35 return GPOINTER_TO_INT(a) - GPOINTER_TO_INT(b);
38 int
39 wmem_compare_uint(const void *a, const void *b)
41 return GPOINTER_TO_UINT(a) > GPOINTER_TO_UINT(b) ? 1 : (GPOINTER_TO_UINT(a) < GPOINTER_TO_UINT(b) ? -1 : 0);
45 * Editor modelines - https://www.wireshark.org/tools/modelines.html
47 * Local variables:
48 * c-basic-offset: 4
49 * tab-width: 8
50 * indent-tabs-mode: nil
51 * End:
53 * vi: set shiftwidth=4 tabstop=8 expandtab:
54 * :indentSize=4:tabSize=8:noTabs=true: