Debian Codegraph @

liblomiri-app-launch/string-util.h

raw
1 /*
2 * Copyright © 2017 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 3, as published
6 * by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranties of
10 * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
11 * PURPOSE. See the GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License along
14 * with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authors:
17 * Pete Woods <[email protected]>
18 */
19
20 #include <glib.h>
21 #include <memory>
22
23 #pragma once
24 #pragma GCC visibility push(default)
25
26 namespace lomiri
27 {
28 namespace app_launch
29 {
30
31 typedef std::unique_ptr<gchar, decltype(&g_free)> GCharUPtr;
32
33 inline GCharUPtr unique_gchar(gchar* s)
34 {
35 return GCharUPtr(s, &g_free);
36 }
37
38 typedef std::unique_ptr<gchar*, decltype(&g_strfreev)> GCharVUPtr;
39
40 inline GCharVUPtr unique_gcharv(gchar** s)
41 {
42 return GCharVUPtr(s, &g_strfreev);
43 }
44
45 } // namespace app_launch
46 } // namespace lomiri
47
48 #pragma GCC visibility pop