Debian Codegraph @

src/dex-thread-storage.c

raw symbols SCIP
1 /*
2 * dex-thread-storage.c
3 *
4 * Copyright 2022 Christian Hergert <[email protected]>
5 *
6 * This library is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU Lesser General Public License as
8 * published by the Free Software Foundation; either version 2.1 of the
9 * License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with this program. If not, see <http://www.gnu.org/licenses/>.
18 *
19 * SPDX-License-Identifier: LGPL-2.1-or-later
20 */
21
22 #include "config.h"
23
24 #include "dex-thread-storage-private.h"
25
26 static GPrivate dex_thread_storage_key = G_PRIVATE_INIT (g_free);
27
28 DexThreadStorage *
29 dex_thread_storage_get (void)
30 {
31 DexThreadStorage *ret = g_private_get (&dex_thread_storage_key);
32
33 if G_UNLIKELY (ret == NULL)
34 {
35 ret = g_new0 (DexThreadStorage, 1);
36 g_private_set (&dex_thread_storage_key, ret);
37 }
38
39 return ret;
40 }
41
42 DexThreadStorage *
43 dex_thread_storage_peek (void)
44 {
45 return g_private_get (&dex_thread_storage_key);
46 }