1 /* grefstring.h: Reference counted strings
3 * Copyright 2018 Emmanuele Bassi
5 * SPDX-License-Identifier: LGPL-2.1-or-later
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, see <http://www.gnu.org/licenses/>.
28 GLIB_AVAILABLE_IN_2_58
29 char * g_ref_string_new (const char *str);
30 GLIB_AVAILABLE_IN_2_58
31 char * g_ref_string_new_len (const char *str,
33 GLIB_AVAILABLE_IN_2_58
34 char * g_ref_string_new_intern (const char *str);
36 GLIB_AVAILABLE_IN_2_58
37 char * g_ref_string_acquire (char *str);
38 GLIB_AVAILABLE_IN_2_58
39 void g_ref_string_release (char *str);
41 GLIB_AVAILABLE_IN_2_58
42 gsize g_ref_string_length (char *str);
47 * A typedef for a reference-counted string. A pointer to a #GRefString can be
48 * treated like a standard `char*` array by all code, but can additionally have
49 * `g_ref_string_*()` methods called on it. `g_ref_string_*()` methods cannot be
50 * called on `char*` arrays not allocated using g_ref_string_new().
52 * If using #GRefString with autocleanups, g_autoptr() must be used rather than
53 * g_autofree(), so that the reference counting metadata is also freed.
57 typedef char GRefString;