xref: /aosp_15_r20/external/webrtc/modules/portal/scoped_glib.cc (revision d9f758449e529ab9291ac668be2861e7a55c2422)
1 /*
2  *  Copyright 2022 The WebRTC project authors. All Rights Reserved.
3  *
4  *  Use of this source code is governed by a BSD-style license
5  *  that can be found in the LICENSE file in the root of the source
6  *  tree. An additional intellectual property rights grant can be found
7  *  in the file PATENTS.  All contributing project authors may
8  *  be found in the AUTHORS file in the root of the source tree.
9  */
10 
11 #include "modules/portal/scoped_glib.h"
12 
13 namespace webrtc {
14 
15 template <>
~Scoped()16 Scoped<GError>::~Scoped() {
17   if (ptr_) {
18     g_error_free(ptr_);
19   }
20 }
21 
22 template <>
~Scoped()23 Scoped<char>::~Scoped() {
24   if (ptr_) {
25     g_free(ptr_);
26   }
27 }
28 
29 template <>
~Scoped()30 Scoped<GVariant>::~Scoped() {
31   if (ptr_) {
32     g_variant_unref(ptr_);
33   }
34 }
35 
36 template <>
~Scoped()37 Scoped<GVariantIter>::~Scoped() {
38   if (ptr_) {
39     g_variant_iter_free(ptr_);
40   }
41 }
42 
43 template <>
~Scoped()44 Scoped<GDBusMessage>::~Scoped() {
45   if (ptr_) {
46     g_object_unref(ptr_);
47   }
48 }
49 
50 template <>
~Scoped()51 Scoped<GUnixFDList>::~Scoped() {
52   if (ptr_) {
53     g_object_unref(ptr_);
54   }
55 }
56 
57 }  // namespace webrtc
58