Move to kernel style SPDX license identifiers
[babeltrace.git] / src / compat / glib.h
... / ...
CommitLineData
1/*
2 * SPDX-License-Identifier: MIT
3 *
4 * Copyright (C) 2015 Michael Jeanson <mjeanson@efficios.com>
5 */
6
7#ifndef _BABELTRACE_COMPAT_GLIB_H
8#define _BABELTRACE_COMPAT_GLIB_H
9
10#include <glib.h>
11
12#if GLIB_CHECK_VERSION(2,31,8)
13
14static inline gboolean
15bt_g_hash_table_contains(GHashTable *hash_table, gconstpointer key)
16{
17 return g_hash_table_contains(hash_table, key);
18}
19
20#else
21
22static inline gboolean
23bt_g_hash_table_contains(GHashTable *hash_table, gconstpointer key)
24{
25 gpointer orig_key;
26 gpointer value;
27
28 return g_hash_table_lookup_extended(hash_table, key, &orig_key,
29 &value);
30}
31
32#endif
33
34
35#if GLIB_CHECK_VERSION(2,29,16)
36
37static inline GPtrArray *
38bt_g_ptr_array_new_full(guint reserved_size,
39 GDestroyNotify element_free_func)
40{
41 return g_ptr_array_new_full(reserved_size, element_free_func);
42}
43
44#else
45
46static inline GPtrArray *
47bt_g_ptr_array_new_full(guint reserved_size,
48 GDestroyNotify element_free_func)
49{
50 GPtrArray *array;
51
52 array = g_ptr_array_sized_new(reserved_size);
53 if (!array) {
54 goto end;
55 }
56 g_ptr_array_set_free_func(array, element_free_func);
57end:
58 return array;
59}
60#endif
61
62#endif /* _BABELTRACE_COMPAT_GLIB_H */
This page took 0.022246 seconds and 4 git commands to generate.