Coverage Report

Created: 2026-08-31 07:21

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/irssi/subprojects/glib-2.74.7/gobject/gboxed.c
Line
Count
Source
1
/* GObject - GLib Type, Object, Parameter and Signal Library
2
 * Copyright (C) 2000-2001 Red Hat, Inc.
3
 *
4
 * SPDX-License-Identifier: LGPL-2.1-or-later
5
 *
6
 * This library is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU Lesser General Public
8
 * License as published by the Free Software Foundation; either
9
 * version 2.1 of the License, or (at your option) any later version.
10
 *
11
 * This library is distributed in the hope that it will be useful,
12
 * but 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 Lesser General
17
 * Public License along with this library; if not, see <http://www.gnu.org/licenses/>.
18
 */
19
20
#include "config.h"
21
22
#include <string.h>
23
24
/* for GValueArray */
25
#ifndef GLIB_DISABLE_DEPRECATION_WARNINGS
26
#define GLIB_DISABLE_DEPRECATION_WARNINGS
27
#endif
28
29
#include "gboxed.h"
30
#include "gclosure.h"
31
#include "gtype-private.h"
32
#include "gvalue.h"
33
#include "gvaluearray.h"
34
#include "gvaluecollector.h"
35
36
37
/**
38
 * SECTION:gboxed
39
 * @short_description: A mechanism to wrap opaque C structures registered
40
 *     by the type system
41
 * @see_also: #GParamSpecBoxed, g_param_spec_boxed()
42
 * @title: Boxed Types
43
 *
44
 * #GBoxed is a generic wrapper mechanism for arbitrary C structures.
45
 *
46
 * The only thing the type system needs to know about the structures is how to
47
 * copy them (a #GBoxedCopyFunc) and how to free them (a #GBoxedFreeFunc);
48
 * beyond that, they are treated as opaque chunks of memory.
49
 *
50
 * Boxed types are useful for simple value-holder structures like rectangles or
51
 * points. They can also be used for wrapping structures defined in non-#GObject
52
 * based libraries. They allow arbitrary structures to be handled in a uniform
53
 * way, allowing uniform copying (or referencing) and freeing (or unreferencing)
54
 * of them, and uniform representation of the type of the contained structure.
55
 * In turn, this allows any type which can be boxed to be set as the data in a
56
 * #GValue, which allows for polymorphic handling of a much wider range of data
57
 * types, and hence usage of such types as #GObject property values.
58
 *
59
 * #GBoxed is designed so that reference counted types can be boxed. Use the
60
 * type’s ‘ref’ function as the #GBoxedCopyFunc, and its ‘unref’ function as the
61
 * #GBoxedFreeFunc. For example, for #GBytes, the #GBoxedCopyFunc is
62
 * g_bytes_ref(), and the #GBoxedFreeFunc is g_bytes_unref().
63
 */
64
65
static inline void              /* keep this function in sync with gvalue.c */
66
value_meminit (GValue *value,
67
         GType   value_type)
68
0
{
69
0
  value->g_type = value_type;
70
0
  memset (value->data, 0, sizeof (value->data));
71
0
}
72
73
static GValue *
74
value_copy (GValue *src_value)
75
0
{
76
0
  GValue *dest_value = g_new0 (GValue, 1);
77
78
0
  if (G_VALUE_TYPE (src_value))
79
0
    {
80
0
      g_value_init (dest_value, G_VALUE_TYPE (src_value));
81
0
      g_value_copy (src_value, dest_value);
82
0
    }
83
0
  return dest_value;
84
0
}
85
86
static void
87
value_free (GValue *value)
88
0
{
89
0
  if (G_VALUE_TYPE (value))
90
0
    g_value_unset (value);
91
0
  g_free (value);
92
0
}
93
94
static GPollFD *
95
pollfd_copy (GPollFD *src)
96
0
{
97
0
  GPollFD *dest = g_new0 (GPollFD, 1);
98
  /* just a couple of integers */
99
0
  memcpy (dest, src, sizeof (GPollFD));
100
0
  return dest;
101
0
}
102
103
void
104
_g_boxed_type_init (void)
105
8
{
106
8
  const GTypeInfo info = {
107
8
    0,                          /* class_size */
108
8
    NULL,                       /* base_init */
109
8
    NULL,                       /* base_destroy */
110
8
    NULL,                       /* class_init */
111
8
    NULL,                       /* class_destroy */
112
8
    NULL,                       /* class_data */
113
8
    0,                          /* instance_size */
114
8
    0,                          /* n_preallocs */
115
8
    NULL,                       /* instance_init */
116
8
    NULL,                       /* value_table */
117
8
  };
118
8
  const GTypeFundamentalInfo finfo = { G_TYPE_FLAG_DERIVABLE, };
119
8
  GType type G_GNUC_UNUSED  /* when compiling with G_DISABLE_ASSERT */;
120
121
  /* G_TYPE_BOXED
122
   */
123
8
  type = g_type_register_fundamental (G_TYPE_BOXED, g_intern_static_string ("GBoxed"), &info, &finfo,
124
8
              G_TYPE_FLAG_ABSTRACT | G_TYPE_FLAG_VALUE_ABSTRACT);
125
8
  g_assert (type == G_TYPE_BOXED);
126
8
}
127
128
static GString *
129
gstring_copy (GString *src_gstring)
130
0
{
131
0
  return g_string_new_len (src_gstring->str, src_gstring->len);
132
0
}
133
134
static void
135
gstring_free (GString *gstring)
136
0
{
137
0
  g_string_free (gstring, TRUE);
138
0
}
139
140
0
G_DEFINE_BOXED_TYPE (GClosure, g_closure, g_closure_ref, g_closure_unref)
141
0
G_DEFINE_BOXED_TYPE (GValue, g_value, value_copy, value_free)
142
32
G_DEFINE_BOXED_TYPE (GValueArray, g_value_array, g_value_array_copy, g_value_array_free)
143
32
G_DEFINE_BOXED_TYPE (GDate, g_date, g_date_copy, g_date_free)
144
0
/* the naming is a bit odd, but GString is obviously not G_TYPE_STRING */
145
0
G_DEFINE_BOXED_TYPE (GString, g_gstring, gstring_copy, gstring_free)
146
0
G_DEFINE_BOXED_TYPE (GHashTable, g_hash_table, g_hash_table_ref, g_hash_table_unref)
147
0
G_DEFINE_BOXED_TYPE (GArray, g_array, g_array_ref, g_array_unref)
148
0
G_DEFINE_BOXED_TYPE (GPtrArray, g_ptr_array,g_ptr_array_ref, g_ptr_array_unref)
149
0
G_DEFINE_BOXED_TYPE (GByteArray, g_byte_array, g_byte_array_ref, g_byte_array_unref)
150
0
G_DEFINE_BOXED_TYPE (GBytes, g_bytes, g_bytes_ref, g_bytes_unref)
151
0
G_DEFINE_BOXED_TYPE (GTree, g_tree, g_tree_ref, g_tree_unref)
152
0
153
0
G_DEFINE_BOXED_TYPE (GRegex, g_regex, g_regex_ref, g_regex_unref)
154
0
G_DEFINE_BOXED_TYPE (GMatchInfo, g_match_info, g_match_info_ref, g_match_info_unref)
155
0
156
0
#define g_variant_type_get_type g_variant_type_get_gtype
157
0
G_DEFINE_BOXED_TYPE (GVariantType, g_variant_type, g_variant_type_copy, g_variant_type_free)
158
0
#undef g_variant_type_get_type
159
0
160
0
G_DEFINE_BOXED_TYPE (GVariantBuilder, g_variant_builder, g_variant_builder_ref, g_variant_builder_unref)
161
0
G_DEFINE_BOXED_TYPE (GVariantDict, g_variant_dict, g_variant_dict_ref, g_variant_dict_unref)
162
0
163
0
G_DEFINE_BOXED_TYPE (GError, g_error, g_error_copy, g_error_free)
164
0
165
0
G_DEFINE_BOXED_TYPE (GDateTime, g_date_time, g_date_time_ref, g_date_time_unref)
166
0
G_DEFINE_BOXED_TYPE (GTimeZone, g_time_zone, g_time_zone_ref, g_time_zone_unref)
167
0
G_DEFINE_BOXED_TYPE (GKeyFile, g_key_file, g_key_file_ref, g_key_file_unref)
168
0
G_DEFINE_BOXED_TYPE (GMappedFile, g_mapped_file, g_mapped_file_ref, g_mapped_file_unref)
169
0
170
0
G_DEFINE_BOXED_TYPE (GMainLoop, g_main_loop, g_main_loop_ref, g_main_loop_unref)
171
0
G_DEFINE_BOXED_TYPE (GMainContext, g_main_context, g_main_context_ref, g_main_context_unref)
172
0
G_DEFINE_BOXED_TYPE (GSource, g_source, g_source_ref, g_source_unref)
173
0
G_DEFINE_BOXED_TYPE (GPollFD, g_pollfd, pollfd_copy, g_free)
174
0
G_DEFINE_BOXED_TYPE (GMarkupParseContext, g_markup_parse_context, g_markup_parse_context_ref, g_markup_parse_context_unref)
175
0
176
0
G_DEFINE_BOXED_TYPE (GThread, g_thread, g_thread_ref, g_thread_unref)
177
0
G_DEFINE_BOXED_TYPE (GChecksum, g_checksum, g_checksum_copy, g_checksum_free)
178
0
G_DEFINE_BOXED_TYPE (GUri, g_uri, g_uri_ref, g_uri_unref)
179
0
180
0
G_DEFINE_BOXED_TYPE (GOptionGroup, g_option_group, g_option_group_ref, g_option_group_unref)
181
0
G_DEFINE_BOXED_TYPE (GPatternSpec, g_pattern_spec, g_pattern_spec_copy, g_pattern_spec_free);
182
0
183
0
/* This one can't use G_DEFINE_BOXED_TYPE (GStrv, g_strv, g_strdupv, g_strfreev) */
184
0
GType
185
0
g_strv_get_type (void)
186
0
{
187
0
  static gsize static_g_define_type_id = 0;
188
189
0
  if (g_once_init_enter (&static_g_define_type_id))
190
0
    {
191
0
      GType g_define_type_id =
192
0
        g_boxed_type_register_static (g_intern_static_string ("GStrv"),
193
0
                                      (GBoxedCopyFunc) g_strdupv,
194
0
                                      (GBoxedFreeFunc) g_strfreev);
195
196
0
      g_once_init_leave (&static_g_define_type_id, g_define_type_id);
197
0
    }
198
199
0
  return static_g_define_type_id;
200
0
}
201
202
GType
203
g_variant_get_gtype (void)
204
0
{
205
0
  return G_TYPE_VARIANT;
206
0
}
207
208
static void
209
boxed_proxy_value_init (GValue *value)
210
0
{
211
0
  value->data[0].v_pointer = NULL;
212
0
}
213
214
static void
215
boxed_proxy_value_free (GValue *value)
216
0
{
217
0
  if (value->data[0].v_pointer && !(value->data[1].v_uint & G_VALUE_NOCOPY_CONTENTS))
218
0
    _g_type_boxed_free (G_VALUE_TYPE (value), value->data[0].v_pointer);
219
0
}
220
221
static void
222
boxed_proxy_value_copy (const GValue *src_value,
223
      GValue       *dest_value)
224
0
{
225
0
  if (src_value->data[0].v_pointer)
226
0
    dest_value->data[0].v_pointer = _g_type_boxed_copy (G_VALUE_TYPE (src_value), src_value->data[0].v_pointer);
227
0
  else
228
0
    dest_value->data[0].v_pointer = src_value->data[0].v_pointer;
229
0
}
230
231
static gpointer
232
boxed_proxy_value_peek_pointer (const GValue *value)
233
0
{
234
0
  return value->data[0].v_pointer;
235
0
}
236
237
static gchar*
238
boxed_proxy_collect_value (GValue      *value,
239
         guint        n_collect_values,
240
         GTypeCValue *collect_values,
241
         guint        collect_flags)
242
0
{
243
0
  if (!collect_values[0].v_pointer)
244
0
    value->data[0].v_pointer = NULL;
245
0
  else
246
0
    {
247
0
      if (collect_flags & G_VALUE_NOCOPY_CONTENTS)
248
0
  {
249
0
    value->data[0].v_pointer = collect_values[0].v_pointer;
250
0
    value->data[1].v_uint = G_VALUE_NOCOPY_CONTENTS;
251
0
  }
252
0
      else
253
0
  value->data[0].v_pointer = _g_type_boxed_copy (G_VALUE_TYPE (value), collect_values[0].v_pointer);
254
0
    }
255
256
0
  return NULL;
257
0
}
258
259
static gchar*
260
boxed_proxy_lcopy_value (const GValue *value,
261
       guint         n_collect_values,
262
       GTypeCValue  *collect_values,
263
       guint         collect_flags)
264
0
{
265
0
  gpointer *boxed_p = collect_values[0].v_pointer;
266
267
0
  g_return_val_if_fail (boxed_p != NULL, g_strdup_printf ("value location for '%s' passed as NULL", G_VALUE_TYPE_NAME (value)));
268
269
0
  if (!value->data[0].v_pointer)
270
0
    *boxed_p = NULL;
271
0
  else if (collect_flags & G_VALUE_NOCOPY_CONTENTS)
272
0
    *boxed_p = value->data[0].v_pointer;
273
0
  else
274
0
    *boxed_p = _g_type_boxed_copy (G_VALUE_TYPE (value), value->data[0].v_pointer);
275
276
0
  return NULL;
277
0
}
278
279
/**
280
 * g_boxed_type_register_static:
281
 * @name: Name of the new boxed type.
282
 * @boxed_copy: Boxed structure copy function.
283
 * @boxed_free: Boxed structure free function.
284
 *
285
 * This function creates a new %G_TYPE_BOXED derived type id for a new
286
 * boxed type with name @name.
287
 *
288
 * Boxed type handling functions have to be provided to copy and free
289
 * opaque boxed structures of this type.
290
 *
291
 * For the general case, it is recommended to use G_DEFINE_BOXED_TYPE()
292
 * instead of calling g_boxed_type_register_static() directly. The macro 
293
 * will create the appropriate `*_get_type()` function for the boxed type.
294
 *
295
 * Returns: New %G_TYPE_BOXED derived type id for @name.
296
 */
297
GType
298
g_boxed_type_register_static (const gchar   *name,
299
            GBoxedCopyFunc boxed_copy,
300
            GBoxedFreeFunc boxed_free)
301
8
{
302
8
  static const GTypeValueTable vtable = {
303
8
    boxed_proxy_value_init,
304
8
    boxed_proxy_value_free,
305
8
    boxed_proxy_value_copy,
306
8
    boxed_proxy_value_peek_pointer,
307
8
    "p",
308
8
    boxed_proxy_collect_value,
309
8
    "p",
310
8
    boxed_proxy_lcopy_value,
311
8
  };
312
8
  GTypeInfo type_info = {
313
8
    0,      /* class_size */
314
8
    NULL,   /* base_init */
315
8
    NULL,   /* base_finalize */
316
8
    NULL,   /* class_init */
317
8
    NULL,   /* class_finalize */
318
8
    NULL,   /* class_data */
319
8
    0,      /* instance_size */
320
8
    0,      /* n_preallocs */
321
8
    NULL,   /* instance_init */
322
8
    &vtable,    /* value_table */
323
8
  };
324
8
  GType type;
325
326
8
  g_return_val_if_fail (name != NULL, 0);
327
8
  g_return_val_if_fail (boxed_copy != NULL, 0);
328
8
  g_return_val_if_fail (boxed_free != NULL, 0);
329
8
  g_return_val_if_fail (g_type_from_name (name) == 0, 0);
330
331
8
  type = g_type_register_static (G_TYPE_BOXED, name, &type_info, 0);
332
333
  /* install proxy functions upon successful registration */
334
8
  if (type)
335
8
    _g_type_boxed_init (type, boxed_copy, boxed_free);
336
337
8
  return type;
338
8
}
339
340
/**
341
 * g_boxed_copy:
342
 * @boxed_type: The type of @src_boxed.
343
 * @src_boxed: (not nullable): The boxed structure to be copied.
344
 * 
345
 * Provide a copy of a boxed structure @src_boxed which is of type @boxed_type.
346
 * 
347
 * Returns: (transfer full) (not nullable): The newly created copy of the boxed
348
 *    structure.
349
 */
350
gpointer
351
g_boxed_copy (GType         boxed_type,
352
        gconstpointer src_boxed)
353
0
{
354
0
  GTypeValueTable *value_table;
355
0
  gpointer dest_boxed;
356
357
0
  g_return_val_if_fail (G_TYPE_IS_BOXED (boxed_type), NULL);
358
0
  g_return_val_if_fail (G_TYPE_IS_ABSTRACT (boxed_type) == FALSE, NULL);
359
0
  g_return_val_if_fail (src_boxed != NULL, NULL);
360
361
0
  value_table = g_type_value_table_peek (boxed_type);
362
0
  g_assert (value_table != NULL);
363
364
  /* check if our proxying implementation is used, we can short-cut here */
365
0
  if (value_table->value_copy == boxed_proxy_value_copy)
366
0
    dest_boxed = _g_type_boxed_copy (boxed_type, (gpointer) src_boxed);
367
0
  else
368
0
    {
369
0
      GValue src_value, dest_value;
370
371
      /* we heavily rely on third-party boxed type value vtable
372
       * implementations to follow normal boxed value storage
373
       * (data[0].v_pointer is the boxed struct, and
374
       * data[1].v_uint holds the G_VALUE_NOCOPY_CONTENTS flag,
375
       * rest zero).
376
       * but then, we can expect that since we laid out the
377
       * g_boxed_*() API.
378
       * data[1].v_uint&G_VALUE_NOCOPY_CONTENTS shouldn't be set
379
       * after a copy.
380
       */
381
      /* equiv. to g_value_set_static_boxed() */
382
0
      value_meminit (&src_value, boxed_type);
383
0
      src_value.data[0].v_pointer = (gpointer) src_boxed;
384
0
      src_value.data[1].v_uint = G_VALUE_NOCOPY_CONTENTS;
385
386
      /* call third-party code copy function, fingers-crossed */
387
0
      value_meminit (&dest_value, boxed_type);
388
0
      value_table->value_copy (&src_value, &dest_value);
389
390
      /* double check and grouse if things went wrong */
391
0
      if (dest_value.data[1].v_ulong)
392
0
  g_warning ("the copy_value() implementation of type '%s' seems to make use of reserved GValue fields",
393
0
       g_type_name (boxed_type));
394
395
0
      dest_boxed = dest_value.data[0].v_pointer;
396
0
    }
397
398
0
  return dest_boxed;
399
0
}
400
401
/**
402
 * g_boxed_free:
403
 * @boxed_type: The type of @boxed.
404
 * @boxed: (not nullable): The boxed structure to be freed.
405
 *
406
 * Free the boxed structure @boxed which is of type @boxed_type.
407
 */
408
void
409
g_boxed_free (GType    boxed_type,
410
        gpointer boxed)
411
0
{
412
0
  GTypeValueTable *value_table;
413
414
0
  g_return_if_fail (G_TYPE_IS_BOXED (boxed_type));
415
0
  g_return_if_fail (G_TYPE_IS_ABSTRACT (boxed_type) == FALSE);
416
0
  g_return_if_fail (boxed != NULL);
417
418
0
  value_table = g_type_value_table_peek (boxed_type);
419
0
  g_assert (value_table != NULL);
420
421
  /* check if our proxying implementation is used, we can short-cut here */
422
0
  if (value_table->value_free == boxed_proxy_value_free)
423
0
    _g_type_boxed_free (boxed_type, boxed);
424
0
  else
425
0
    {
426
0
      GValue value;
427
428
      /* see g_boxed_copy() on why we think we can do this */
429
0
      value_meminit (&value, boxed_type);
430
0
      value.data[0].v_pointer = boxed;
431
0
      value_table->value_free (&value);
432
0
    }
433
0
}
434
435
/**
436
 * g_value_get_boxed:
437
 * @value: a valid #GValue of %G_TYPE_BOXED derived type
438
 *
439
 * Get the contents of a %G_TYPE_BOXED derived #GValue.
440
 *
441
 * Returns: (transfer none): boxed contents of @value
442
 */
443
gpointer
444
g_value_get_boxed (const GValue *value)
445
0
{
446
0
  g_return_val_if_fail (G_VALUE_HOLDS_BOXED (value), NULL);
447
0
  g_return_val_if_fail (G_TYPE_IS_VALUE (G_VALUE_TYPE (value)), NULL);
448
449
0
  return value->data[0].v_pointer;
450
0
}
451
452
/**
453
 * g_value_dup_boxed: (skip)
454
 * @value: a valid #GValue of %G_TYPE_BOXED derived type
455
 *
456
 * Get the contents of a %G_TYPE_BOXED derived #GValue.  Upon getting,
457
 * the boxed value is duplicated and needs to be later freed with
458
 * g_boxed_free(), e.g. like: g_boxed_free (G_VALUE_TYPE (@value),
459
 * return_value);
460
 *
461
 * Returns: boxed contents of @value
462
 */
463
gpointer
464
g_value_dup_boxed (const GValue *value)
465
0
{
466
0
  g_return_val_if_fail (G_VALUE_HOLDS_BOXED (value), NULL);
467
0
  g_return_val_if_fail (G_TYPE_IS_VALUE (G_VALUE_TYPE (value)), NULL);
468
469
0
  return value->data[0].v_pointer ? g_boxed_copy (G_VALUE_TYPE (value), value->data[0].v_pointer) : NULL;
470
0
}
471
472
static inline void
473
value_set_boxed_internal (GValue       *value,
474
        gconstpointer boxed,
475
        gboolean      need_copy,
476
        gboolean      need_free)
477
0
{
478
0
  if (!boxed)
479
0
    {
480
      /* just resetting to NULL might not be desired, need to
481
       * have value reinitialized also (for values defaulting
482
       * to other default value states than a NULL data pointer),
483
       * g_value_reset() will handle this
484
       */
485
0
      g_value_reset (value);
486
0
      return;
487
0
    }
488
489
0
  if (value->data[0].v_pointer && !(value->data[1].v_uint & G_VALUE_NOCOPY_CONTENTS))
490
0
    g_boxed_free (G_VALUE_TYPE (value), value->data[0].v_pointer);
491
0
  value->data[1].v_uint = need_free ? 0 : G_VALUE_NOCOPY_CONTENTS;
492
0
  value->data[0].v_pointer = need_copy ? g_boxed_copy (G_VALUE_TYPE (value), boxed) : (gpointer) boxed;
493
0
}
494
495
/**
496
 * g_value_set_boxed:
497
 * @value: a valid #GValue of %G_TYPE_BOXED derived type
498
 * @v_boxed: (nullable): boxed value to be set
499
 *
500
 * Set the contents of a %G_TYPE_BOXED derived #GValue to @v_boxed.
501
 */
502
void
503
g_value_set_boxed (GValue       *value,
504
       gconstpointer boxed)
505
0
{
506
0
  g_return_if_fail (G_VALUE_HOLDS_BOXED (value));
507
0
  g_return_if_fail (G_TYPE_IS_VALUE (G_VALUE_TYPE (value)));
508
509
0
  value_set_boxed_internal (value, boxed, TRUE, TRUE);
510
0
}
511
512
/**
513
 * g_value_set_static_boxed:
514
 * @value: a valid #GValue of %G_TYPE_BOXED derived type
515
 * @v_boxed: (nullable): static boxed value to be set
516
 *
517
 * Set the contents of a %G_TYPE_BOXED derived #GValue to @v_boxed.
518
 *
519
 * The boxed value is assumed to be static, and is thus not duplicated
520
 * when setting the #GValue.
521
 */
522
void
523
g_value_set_static_boxed (GValue       *value,
524
        gconstpointer boxed)
525
0
{
526
0
  g_return_if_fail (G_VALUE_HOLDS_BOXED (value));
527
0
  g_return_if_fail (G_TYPE_IS_VALUE (G_VALUE_TYPE (value)));
528
529
0
  value_set_boxed_internal (value, boxed, FALSE, FALSE);
530
0
}
531
532
/**
533
 * g_value_set_boxed_take_ownership:
534
 * @value: a valid #GValue of %G_TYPE_BOXED derived type
535
 * @v_boxed: (nullable): duplicated unowned boxed value to be set
536
 *
537
 * This is an internal function introduced mainly for C marshallers.
538
 *
539
 * Deprecated: 2.4: Use g_value_take_boxed() instead.
540
 */
541
void
542
g_value_set_boxed_take_ownership (GValue       *value,
543
          gconstpointer boxed)
544
0
{
545
0
  g_value_take_boxed (value, boxed);
546
0
}
547
548
/**
549
 * g_value_take_boxed:
550
 * @value: a valid #GValue of %G_TYPE_BOXED derived type
551
 * @v_boxed: (nullable): duplicated unowned boxed value to be set
552
 *
553
 * Sets the contents of a %G_TYPE_BOXED derived #GValue to @v_boxed
554
 * and takes over the ownership of the caller’s reference to @v_boxed;
555
 * the caller doesn’t have to unref it any more.
556
 *
557
 * Since: 2.4
558
 */
559
void
560
g_value_take_boxed (GValue       *value,
561
        gconstpointer boxed)
562
0
{
563
0
  g_return_if_fail (G_VALUE_HOLDS_BOXED (value));
564
0
  g_return_if_fail (G_TYPE_IS_VALUE (G_VALUE_TYPE (value)));
565
566
0
  value_set_boxed_internal (value, boxed, FALSE, TRUE);
567
0
}