| 1 |
/* sysprof-strings-private.h |
| 2 |
* |
| 3 |
* Copyright 2023 Christian Hergert <[email protected]> |
| 4 |
* |
| 5 |
* This program is free software: you can redistribute it and/or modify |
| 6 |
* it under the terms of the GNU General Public License as published by |
| 7 |
* the Free Software Foundation, either version 3 of the License, or |
| 8 |
* (at your option) any later version. |
| 9 |
* |
| 10 |
* This program is distributed in the hope that it will be useful, |
| 11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 |
* GNU General Public License for more details. |
| 14 |
* |
| 15 |
* You should have received a copy of the GNU General Public License |
| 16 |
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 17 |
* |
| 18 |
* SPDX-License-Identifier: GPL-3.0-or-later |
| 19 |
*/ |
| 20 |
|
| 21 |
#pragma once |
| 22 |
|
| 23 |
#include <glib.h> |
| 24 |
|
| 25 |
G_BEGIN_DECLS |
| 26 |
|
| 27 |
typedef struct _SysprofStrings SysprofStrings; |
| 28 |
|
| 29 |
SysprofStrings *sysprof_strings_new (void); |
| 30 |
SysprofStrings *sysprof_strings_ref (SysprofStrings *self); |
| 31 |
void sysprof_strings_unref (SysprofStrings *self); |
| 32 |
GRefString *sysprof_strings_get (SysprofStrings *self, |
| 33 |
const char *string); |
| 34 |
|
| 35 |
#define SYSPROF_STRV_INIT(...) ((const char * const[]){__VA_ARGS__,NULL}) |
| 36 |
|
| 37 |
static inline gboolean |
| 38 |
sysprof_set_strv (char ***dest, |
| 39 |
const char * const *src) |
| 40 |
{ |
| 41 |
if ((const char * const *)*dest == src) |
| 42 |
return FALSE; |
| 43 |
|
| 44 |
if (*dest == NULL || |
| 45 |
src == NULL || |
| 46 |
!g_strv_equal ((const char * const *)*dest, src)) |
| 47 |
{ |
| 48 |
char **copy = g_strdupv ((char **)src); |
| 49 |
g_strfreev (*dest); |
| 50 |
*dest = copy; |
| 51 |
return TRUE; |
| 52 |
} |
| 53 |
|
| 54 |
return FALSE; |
| 55 |
} |
| 56 |
|
| 57 |
G_END_DECLS |