Coverage Report

Created: 2026-02-24 07:11

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/gstreamer/subprojects/glib-2.86.3/glib/gmem.h
Line
Count
Source
1
/* GLIB - Library of useful routines for C programming
2
 * Copyright (C) 1995-1997  Peter Mattis, Spencer Kimball and Josh MacDonald
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 Public
17
 * License along with this library; if not, see <http://www.gnu.org/licenses/>.
18
 */
19
20
/*
21
 * Modified by the GLib Team and others 1997-2000.  See the AUTHORS
22
 * file for a list of people on the GLib Team.  See the ChangeLog
23
 * files for a list of changes.  These files are distributed with
24
 * GLib at ftp://ftp.gtk.org/pub/gtk/.
25
 */
26
27
#ifndef __G_MEM_H__
28
#define __G_MEM_H__
29
30
#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION)
31
#error "Only <glib.h> can be included directly."
32
#endif
33
34
#include <glib/gutils.h>
35
#include <glib/glib-typeof.h>
36
37
G_BEGIN_DECLS
38
39
/**
40
 * GMemVTable:
41
 * @malloc: function to use for allocating memory.
42
 * @realloc: function to use for reallocating memory.
43
 * @free: function to use to free memory.
44
 * @calloc: function to use for allocating zero-filled memory.
45
 * @try_malloc: function to use for allocating memory without a default error handler.
46
 * @try_realloc: function to use for reallocating memory without a default error handler.
47
 * 
48
 * A set of functions used to perform memory allocation. The same #GMemVTable must
49
 * be used for all allocations in the same program; a call to g_mem_set_vtable(),
50
 * if it exists, should be prior to any use of GLib.
51
 *
52
 * This functions related to this has been deprecated in 2.46, and no longer work.
53
 */
54
typedef struct _GMemVTable GMemVTable;
55
56
57
#if GLIB_SIZEOF_VOID_P > GLIB_SIZEOF_LONG
58
/**
59
 * G_MEM_ALIGN:
60
 *
61
 * Indicates the number of bytes to which memory will be aligned on the
62
 * current platform.
63
 */
64
#  define G_MEM_ALIGN GLIB_SIZEOF_VOID_P
65
#else /* GLIB_SIZEOF_VOID_P <= GLIB_SIZEOF_LONG */
66
#  define G_MEM_ALIGN GLIB_SIZEOF_LONG
67
#endif  /* GLIB_SIZEOF_VOID_P <= GLIB_SIZEOF_LONG */
68
69
70
/* Memory allocation functions
71
 */
72
73
GLIB_AVAILABLE_IN_ALL
74
void     (g_free)         (gpointer      mem);
75
GLIB_AVAILABLE_IN_2_76
76
void     g_free_sized     (gpointer      mem,
77
                           size_t        size);
78
79
GLIB_AVAILABLE_IN_2_34
80
void     g_clear_pointer  (gpointer      *pp,
81
                           GDestroyNotify destroy);
82
83
GLIB_AVAILABLE_IN_ALL
84
gpointer g_malloc         (gsize   n_bytes) G_GNUC_MALLOC G_GNUC_ALLOC_SIZE(1);
85
GLIB_AVAILABLE_IN_ALL
86
gpointer g_malloc0        (gsize   n_bytes) G_GNUC_MALLOC G_GNUC_ALLOC_SIZE(1);
87
GLIB_AVAILABLE_IN_ALL
88
gpointer g_realloc        (gpointer  mem,
89
         gsize   n_bytes) G_GNUC_WARN_UNUSED_RESULT;
90
GLIB_AVAILABLE_IN_ALL
91
gpointer g_try_malloc     (gsize   n_bytes) G_GNUC_MALLOC G_GNUC_ALLOC_SIZE(1);
92
GLIB_AVAILABLE_IN_ALL
93
gpointer g_try_malloc0    (gsize   n_bytes) G_GNUC_MALLOC G_GNUC_ALLOC_SIZE(1);
94
GLIB_AVAILABLE_IN_ALL
95
gpointer g_try_realloc    (gpointer  mem,
96
         gsize   n_bytes) G_GNUC_WARN_UNUSED_RESULT;
97
98
GLIB_AVAILABLE_IN_ALL
99
gpointer g_malloc_n       (gsize   n_blocks,
100
         gsize   n_block_bytes) G_GNUC_MALLOC G_GNUC_ALLOC_SIZE2(1,2);
101
GLIB_AVAILABLE_IN_ALL
102
gpointer g_malloc0_n      (gsize   n_blocks,
103
         gsize   n_block_bytes) G_GNUC_MALLOC G_GNUC_ALLOC_SIZE2(1,2);
104
GLIB_AVAILABLE_IN_ALL
105
gpointer g_realloc_n      (gpointer  mem,
106
         gsize   n_blocks,
107
         gsize   n_block_bytes) G_GNUC_WARN_UNUSED_RESULT;
108
GLIB_AVAILABLE_IN_ALL
109
gpointer g_try_malloc_n   (gsize   n_blocks,
110
         gsize   n_block_bytes) G_GNUC_MALLOC G_GNUC_ALLOC_SIZE2(1,2);
111
GLIB_AVAILABLE_IN_ALL
112
gpointer g_try_malloc0_n  (gsize   n_blocks,
113
         gsize   n_block_bytes) G_GNUC_MALLOC G_GNUC_ALLOC_SIZE2(1,2);
114
GLIB_AVAILABLE_IN_ALL
115
gpointer g_try_realloc_n  (gpointer  mem,
116
         gsize   n_blocks,
117
         gsize   n_block_bytes) G_GNUC_WARN_UNUSED_RESULT;
118
119
GLIB_AVAILABLE_IN_2_72
120
gpointer g_aligned_alloc  (gsize         n_blocks,
121
                           gsize         n_block_bytes,
122
                           gsize         alignment) G_GNUC_WARN_UNUSED_RESULT G_GNUC_ALLOC_SIZE2(1,2);
123
GLIB_AVAILABLE_IN_2_72
124
gpointer g_aligned_alloc0 (gsize         n_blocks,
125
                           gsize         n_block_bytes,
126
                           gsize         alignment) G_GNUC_WARN_UNUSED_RESULT G_GNUC_ALLOC_SIZE2(1,2);
127
GLIB_AVAILABLE_IN_2_72
128
void     g_aligned_free   (gpointer      mem);
129
GLIB_AVAILABLE_IN_2_76
130
void     g_aligned_free_sized (gpointer  mem,
131
                               size_t    alignment,
132
                               size_t    size);
133
134
#if defined(glib_typeof) && GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_58
135
#define g_clear_pointer(pp, destroy)                     \
136
3.54M
  G_STMT_START                                           \
137
3.54M
  {                                                      \
138
3.54M
    G_STATIC_ASSERT (sizeof *(pp) == sizeof (gpointer)); \
139
3.54M
    glib_typeof ((pp)) _pp = (pp);                       \
140
3.54M
    glib_typeof (*(pp)) _ptr = *_pp;                     \
141
3.54M
    *_pp = NULL;                                         \
142
3.54M
    if (_ptr)                                            \
143
3.54M
      (destroy) (_ptr);                                  \
144
3.54M
  }                                                      \
145
3.54M
  G_STMT_END                                             \
146
24
  GLIB_AVAILABLE_MACRO_IN_2_34
147
#else /* __GNUC__ */
148
#define g_clear_pointer(pp, destroy) \
149
  G_STMT_START {                                                               \
150
    G_STATIC_ASSERT (sizeof *(pp) == sizeof (gpointer));                       \
151
    /* Only one access, please; work around type aliasing */                   \
152
    union { char *in; gpointer *out; } _pp;                                    \
153
    gpointer _p;                                                               \
154
    /* This assignment is needed to avoid a gcc warning */                     \
155
    GDestroyNotify _destroy = (GDestroyNotify) (destroy);                      \
156
                                                                               \
157
    _pp.in = (char *) (pp);                                                    \
158
    _p = *_pp.out;                                                             \
159
    if (_p)                        \
160
      {                        \
161
        *_pp.out = NULL;                                                       \
162
        _destroy (_p);                                                         \
163
      }                                                                        \
164
  } G_STMT_END                                                                 \
165
  GLIB_AVAILABLE_MACRO_IN_2_34
166
#endif /* __GNUC__ */
167
168
169
#if G_GNUC_CHECK_VERSION (4, 1) && GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_78 && defined(G_HAVE_FREE_SIZED)
170
171
#define g_free(mem)                                                            \
172
  (__builtin_object_size ((mem), 0) != ((size_t) - 1)) ?                       \
173
    g_free_sized (mem, __builtin_object_size ((mem), 0)) : (g_free) (mem)
174
175
#endif /* G_GNUC_CHECK_VERSION (4, 1) && && GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_78 && defined(G_HAVE_FREE_SIZED) */
176
177
/**
178
 * g_steal_pointer:
179
 * @pp: (not nullable): a pointer to a pointer
180
 *
181
 * Sets @pp to %NULL, returning the value that was there before.
182
 *
183
 * Conceptually, this transfers the ownership of the pointer from the
184
 * referenced variable to the "caller" of the macro (ie: "steals" the
185
 * reference).
186
 *
187
 * The return value will be properly typed, according to the type of
188
 * @pp.
189
 *
190
 * This can be very useful when combined with g_autoptr() to prevent the
191
 * return value of a function from being automatically freed.  Consider
192
 * the following example (which only works on GCC and clang):
193
 *
194
 * |[
195
 * GObject *
196
 * create_object (void)
197
 * {
198
 *   g_autoptr(GObject) obj = g_object_new (G_TYPE_OBJECT, NULL);
199
 *
200
 *   if (early_error_case)
201
 *     return NULL;
202
 *
203
 *   return g_steal_pointer (&obj);
204
 * }
205
 * ]|
206
 *
207
 * It can also be used in similar ways for 'out' parameters and is
208
 * particularly useful for dealing with optional out parameters:
209
 *
210
 * |[
211
 * gboolean
212
 * get_object (GObject **obj_out)
213
 * {
214
 *   g_autoptr(GObject) obj = g_object_new (G_TYPE_OBJECT, NULL);
215
 *
216
 *   if (early_error_case)
217
 *     return FALSE;
218
 *
219
 *   if (obj_out)
220
 *     *obj_out = g_steal_pointer (&obj);
221
 *
222
 *   return TRUE;
223
 * }
224
 * ]|
225
 *
226
 * In the above example, the object will be automatically freed in the
227
 * early error case and also in the case that %NULL was given for
228
 * @obj_out.
229
 *
230
 * Since: 2.44
231
 */
232
GLIB_AVAILABLE_STATIC_INLINE_IN_2_44
233
static inline gpointer g_steal_pointer (gpointer pp);
234
235
GLIB_AVAILABLE_STATIC_INLINE_IN_2_44
236
static inline gpointer
237
g_steal_pointer (gpointer pp)
238
684k
{
239
684k
  gpointer *ptr = (gpointer *) pp;
240
684k
  gpointer ref;
241
242
684k
  ref = *ptr;
243
684k
  *ptr = NULL;
244
245
684k
  return ref;
246
684k
}
Unexecuted instantiation: typefind.c:g_steal_pointer
Unexecuted instantiation: gst-discoverer.c:g_steal_pointer
Unexecuted instantiation: gstenumtypes.c:g_steal_pointer
Unexecuted instantiation: lex.priv_gst_parse_yy.c:g_steal_pointer
Unexecuted instantiation: grammar.tab.c:g_steal_pointer
Unexecuted instantiation: gst.c:g_steal_pointer
Unexecuted instantiation: gstobject.c:g_steal_pointer
Unexecuted instantiation: gstallocator.c:g_steal_pointer
Unexecuted instantiation: gstbin.c:g_steal_pointer
Unexecuted instantiation: gstbuffer.c:g_steal_pointer
Unexecuted instantiation: gstbufferlist.c:g_steal_pointer
Unexecuted instantiation: gstbufferpool.c:g_steal_pointer
gstbus.c:g_steal_pointer
Line
Count
Source
238
72.7k
{
239
72.7k
  gpointer *ptr = (gpointer *) pp;
240
72.7k
  gpointer ref;
241
242
72.7k
  ref = *ptr;
243
72.7k
  *ptr = NULL;
244
245
72.7k
  return ref;
246
72.7k
}
Unexecuted instantiation: gstcaps.c:g_steal_pointer
Unexecuted instantiation: gstcapsfeatures.c:g_steal_pointer
Unexecuted instantiation: gstchildproxy.c:g_steal_pointer
Unexecuted instantiation: gstclock.c:g_steal_pointer
Unexecuted instantiation: gstcontext.c:g_steal_pointer
Unexecuted instantiation: gstcontrolbinding.c:g_steal_pointer
Unexecuted instantiation: gstcontrolsource.c:g_steal_pointer
Unexecuted instantiation: gstdatetime.c:g_steal_pointer
Unexecuted instantiation: gstdebugutils.c:g_steal_pointer
Unexecuted instantiation: gstdevice.c:g_steal_pointer
Unexecuted instantiation: gstdeviceprovider.c:g_steal_pointer
Unexecuted instantiation: gstdeviceproviderfactory.c:g_steal_pointer
Unexecuted instantiation: gstdynamictypefactory.c:g_steal_pointer
Unexecuted instantiation: gstelement.c:g_steal_pointer
Unexecuted instantiation: gstelementfactory.c:g_steal_pointer
Unexecuted instantiation: gsterror.c:g_steal_pointer
Unexecuted instantiation: gstevent.c:g_steal_pointer
Unexecuted instantiation: gstformat.c:g_steal_pointer
Unexecuted instantiation: gstghostpad.c:g_steal_pointer
Unexecuted instantiation: gstdevicemonitor.c:g_steal_pointer
Unexecuted instantiation: gstidstr.c:g_steal_pointer
Unexecuted instantiation: gstinfo.c:g_steal_pointer
Unexecuted instantiation: gstiterator.c:g_steal_pointer
Unexecuted instantiation: gstatomicqueue.c:g_steal_pointer
Unexecuted instantiation: gstmessage.c:g_steal_pointer
Unexecuted instantiation: gstmeta.c:g_steal_pointer
Unexecuted instantiation: gstmetafactory.c:g_steal_pointer
Unexecuted instantiation: gstmemory.c:g_steal_pointer
Unexecuted instantiation: gstminiobject.c:g_steal_pointer
Unexecuted instantiation: gstpad.c:g_steal_pointer
Unexecuted instantiation: gstpadtemplate.c:g_steal_pointer
Unexecuted instantiation: gstparamspecs.c:g_steal_pointer
Unexecuted instantiation: gstpipeline.c:g_steal_pointer
Unexecuted instantiation: gstplugin.c:g_steal_pointer
Unexecuted instantiation: gstpluginfeature.c:g_steal_pointer
Unexecuted instantiation: gstpoll.c:g_steal_pointer
Unexecuted instantiation: gstpreset.c:g_steal_pointer
Unexecuted instantiation: gstprotection.c:g_steal_pointer
Unexecuted instantiation: gstquery.c:g_steal_pointer
Unexecuted instantiation: gstregistry.c:g_steal_pointer
Unexecuted instantiation: gstregistrychunks.c:g_steal_pointer
Unexecuted instantiation: gstpromise.c:g_steal_pointer
Unexecuted instantiation: gstsample.c:g_steal_pointer
Unexecuted instantiation: gstsegment.c:g_steal_pointer
Unexecuted instantiation: gststreamcollection.c:g_steal_pointer
Unexecuted instantiation: gststreams.c:g_steal_pointer
Unexecuted instantiation: gststructure.c:g_steal_pointer
Unexecuted instantiation: gstsystemclock.c:g_steal_pointer
Unexecuted instantiation: gsttaglist.c:g_steal_pointer
Unexecuted instantiation: gsttagsetter.c:g_steal_pointer
Unexecuted instantiation: gsttask.c:g_steal_pointer
Unexecuted instantiation: gsttaskpool.c:g_steal_pointer
Unexecuted instantiation: gsttoc.c:g_steal_pointer
Unexecuted instantiation: gsttocsetter.c:g_steal_pointer
Unexecuted instantiation: gsttracer.c:g_steal_pointer
Unexecuted instantiation: gsttracerfactory.c:g_steal_pointer
Unexecuted instantiation: gsttracerrecord.c:g_steal_pointer
Unexecuted instantiation: gsttracerutils.c:g_steal_pointer
Unexecuted instantiation: gsttypefind.c:g_steal_pointer
Unexecuted instantiation: gsttypefindfactory.c:g_steal_pointer
Unexecuted instantiation: gsturi.c:g_steal_pointer
Unexecuted instantiation: gstutils.c:g_steal_pointer
Unexecuted instantiation: gstvalue.c:g_steal_pointer
Unexecuted instantiation: gstvecdeque.c:g_steal_pointer
Unexecuted instantiation: gstparse.c:g_steal_pointer
Unexecuted instantiation: gstcpuid.c:g_steal_pointer
Unexecuted instantiation: gstpluginloader.c:g_steal_pointer
Unexecuted instantiation: gstregistrybinary.c:g_steal_pointer
Unexecuted instantiation: printf.c:g_steal_pointer
Unexecuted instantiation: printf-extension.c:g_steal_pointer
Unexecuted instantiation: vasnprintf.c:g_steal_pointer
Unexecuted instantiation: printf-args.c:g_steal_pointer
Unexecuted instantiation: printf-parse.c:g_steal_pointer
Unexecuted instantiation: gallocator.c:g_steal_pointer
Unexecuted instantiation: gcache.c:g_steal_pointer
Unexecuted instantiation: gcompletion.c:g_steal_pointer
Unexecuted instantiation: grel.c:g_steal_pointer
Unexecuted instantiation: gthread-deprecated.c:g_steal_pointer
Unexecuted instantiation: garcbox.c:g_steal_pointer
garray.c:g_steal_pointer
Line
Count
Source
238
5.43k
{
239
5.43k
  gpointer *ptr = (gpointer *) pp;
240
5.43k
  gpointer ref;
241
242
5.43k
  ref = *ptr;
243
5.43k
  *ptr = NULL;
244
245
5.43k
  return ref;
246
5.43k
}
Unexecuted instantiation: gasyncqueue.c:g_steal_pointer
Unexecuted instantiation: gbacktrace.c:g_steal_pointer
Unexecuted instantiation: gbase64.c:g_steal_pointer
Unexecuted instantiation: gbitlock.c:g_steal_pointer
Unexecuted instantiation: gbookmarkfile.c:g_steal_pointer
Unexecuted instantiation: gbytes.c:g_steal_pointer
Unexecuted instantiation: gcharset.c:g_steal_pointer
Unexecuted instantiation: gchecksum.c:g_steal_pointer
Unexecuted instantiation: gconvert.c:g_steal_pointer
Unexecuted instantiation: gdataset.c:g_steal_pointer
Unexecuted instantiation: gdate.c:g_steal_pointer
Unexecuted instantiation: gdatetime.c:g_steal_pointer
Unexecuted instantiation: gdatetime-private.c:g_steal_pointer
Unexecuted instantiation: gdir.c:g_steal_pointer
Unexecuted instantiation: genviron.c:g_steal_pointer
Unexecuted instantiation: gerror.c:g_steal_pointer
Unexecuted instantiation: gfileutils.c:g_steal_pointer
Unexecuted instantiation: ggettext.c:g_steal_pointer
ghash.c:g_steal_pointer
Line
Count
Source
238
63
{
239
63
  gpointer *ptr = (gpointer *) pp;
240
63
  gpointer ref;
241
242
63
  ref = *ptr;
243
63
  *ptr = NULL;
244
245
63
  return ref;
246
63
}
Unexecuted instantiation: ghmac.c:g_steal_pointer
Unexecuted instantiation: ghook.c:g_steal_pointer
Unexecuted instantiation: ghostutils.c:g_steal_pointer
Unexecuted instantiation: giochannel.c:g_steal_pointer
Unexecuted instantiation: gkeyfile.c:g_steal_pointer
Unexecuted instantiation: glib-init.c:g_steal_pointer
Unexecuted instantiation: glib-private.c:g_steal_pointer
Unexecuted instantiation: glist.c:g_steal_pointer
Unexecuted instantiation: gmain.c:g_steal_pointer
Unexecuted instantiation: gmappedfile.c:g_steal_pointer
Unexecuted instantiation: gmarkup.c:g_steal_pointer
Unexecuted instantiation: gmem.c:g_steal_pointer
Unexecuted instantiation: gmessages.c:g_steal_pointer
Unexecuted instantiation: gnode.c:g_steal_pointer
Unexecuted instantiation: goption.c:g_steal_pointer
Unexecuted instantiation: gpathbuf.c:g_steal_pointer
Unexecuted instantiation: gpattern.c:g_steal_pointer
Unexecuted instantiation: gpoll.c:g_steal_pointer
Unexecuted instantiation: gqsort.c:g_steal_pointer
Unexecuted instantiation: gquark.c:g_steal_pointer
Unexecuted instantiation: gqueue.c:g_steal_pointer
Unexecuted instantiation: grand.c:g_steal_pointer
Unexecuted instantiation: grcbox.c:g_steal_pointer
Unexecuted instantiation: grefcount.c:g_steal_pointer
Unexecuted instantiation: grefstring.c:g_steal_pointer
Unexecuted instantiation: gregex.c:g_steal_pointer
Unexecuted instantiation: gscanner.c:g_steal_pointer
Unexecuted instantiation: gsequence.c:g_steal_pointer
Unexecuted instantiation: gshell.c:g_steal_pointer
Unexecuted instantiation: gslice.c:g_steal_pointer
Unexecuted instantiation: gslist.c:g_steal_pointer
Unexecuted instantiation: gspawn.c:g_steal_pointer
Unexecuted instantiation: gstdio.c:g_steal_pointer
Unexecuted instantiation: gstrfuncs.c:g_steal_pointer
Unexecuted instantiation: gstring.c:g_steal_pointer
Unexecuted instantiation: gstringchunk.c:g_steal_pointer
Unexecuted instantiation: gstrvbuilder.c:g_steal_pointer
Unexecuted instantiation: gtestutils.c:g_steal_pointer
gthread.c:g_steal_pointer
Line
Count
Source
238
100
{
239
100
  gpointer *ptr = (gpointer *) pp;
240
100
  gpointer ref;
241
242
100
  ref = *ptr;
243
100
  *ptr = NULL;
244
245
100
  return ref;
246
100
}
gthreadpool.c:g_steal_pointer
Line
Count
Source
238
556
{
239
556
  gpointer *ptr = (gpointer *) pp;
240
556
  gpointer ref;
241
242
556
  ref = *ptr;
243
556
  *ptr = NULL;
244
245
556
  return ref;
246
556
}
Unexecuted instantiation: gtimer.c:g_steal_pointer
Unexecuted instantiation: gtimezone.c:g_steal_pointer
Unexecuted instantiation: gtrace.c:g_steal_pointer
Unexecuted instantiation: gtranslit.c:g_steal_pointer
Unexecuted instantiation: gtree.c:g_steal_pointer
Unexecuted instantiation: guniprop.c:g_steal_pointer
Unexecuted instantiation: gutf8.c:g_steal_pointer
Unexecuted instantiation: gunicollate.c:g_steal_pointer
Unexecuted instantiation: gunidecomp.c:g_steal_pointer
Unexecuted instantiation: guri.c:g_steal_pointer
gutils.c:g_steal_pointer
Line
Count
Source
238
8
{
239
8
  gpointer *ptr = (gpointer *) pp;
240
8
  gpointer ref;
241
242
8
  ref = *ptr;
243
8
  *ptr = NULL;
244
245
8
  return ref;
246
8
}
Unexecuted instantiation: guuid.c:g_steal_pointer
Unexecuted instantiation: gvariant.c:g_steal_pointer
Unexecuted instantiation: gvariant-core.c:g_steal_pointer
Unexecuted instantiation: gvariant-parser.c:g_steal_pointer
Unexecuted instantiation: gvariant-serialiser.c:g_steal_pointer
Unexecuted instantiation: gvarianttypeinfo.c:g_steal_pointer
Unexecuted instantiation: gvarianttype.c:g_steal_pointer
Unexecuted instantiation: gwakeup.c:g_steal_pointer
Unexecuted instantiation: gprint.c:g_steal_pointer
Unexecuted instantiation: gprintf.c:g_steal_pointer
Unexecuted instantiation: glib-unix.c:g_steal_pointer
Unexecuted instantiation: giounix.c:g_steal_pointer
Unexecuted instantiation: gspawn-posix.c:g_steal_pointer
Unexecuted instantiation: glib-enumtypes.c:g_steal_pointer
Unexecuted instantiation: gatomicarray.c:g_steal_pointer
Unexecuted instantiation: gbinding.c:g_steal_pointer
Unexecuted instantiation: gbindinggroup.c:g_steal_pointer
Unexecuted instantiation: gboxed.c:g_steal_pointer
Unexecuted instantiation: gclosure.c:g_steal_pointer
Unexecuted instantiation: genums.c:g_steal_pointer
Unexecuted instantiation: gmarshal.c:g_steal_pointer
gobject.c:g_steal_pointer
Line
Count
Source
238
605k
{
239
605k
  gpointer *ptr = (gpointer *) pp;
240
605k
  gpointer ref;
241
242
605k
  ref = *ptr;
243
605k
  *ptr = NULL;
244
245
605k
  return ref;
246
605k
}
Unexecuted instantiation: gparam.c:g_steal_pointer
Unexecuted instantiation: gparamspecs.c:g_steal_pointer
Unexecuted instantiation: gsignal.c:g_steal_pointer
Unexecuted instantiation: gsignalgroup.c:g_steal_pointer
Unexecuted instantiation: gsourceclosure.c:g_steal_pointer
Unexecuted instantiation: gtype.c:g_steal_pointer
Unexecuted instantiation: gtypemodule.c:g_steal_pointer
Unexecuted instantiation: gtypeplugin.c:g_steal_pointer
Unexecuted instantiation: gvalue.c:g_steal_pointer
Unexecuted instantiation: gvaluearray.c:g_steal_pointer
Unexecuted instantiation: gvaluetransform.c:g_steal_pointer
Unexecuted instantiation: gvaluetypes.c:g_steal_pointer
Unexecuted instantiation: gmodule.c:g_steal_pointer
Unexecuted instantiation: gmodule-deprecated.c:g_steal_pointer
Unexecuted instantiation: pbutils-enumtypes.c:g_steal_pointer
Unexecuted instantiation: gstpluginsbaseversion.c:g_steal_pointer
Unexecuted instantiation: pbutils.c:g_steal_pointer
Unexecuted instantiation: codec-utils.c:g_steal_pointer
Unexecuted instantiation: descriptions.c:g_steal_pointer
Unexecuted instantiation: encoding-profile.c:g_steal_pointer
Unexecuted instantiation: encoding-target.c:g_steal_pointer
Unexecuted instantiation: install-plugins.c:g_steal_pointer
Unexecuted instantiation: missing-plugins.c:g_steal_pointer
Unexecuted instantiation: gstaudiovisualizer.c:g_steal_pointer
Unexecuted instantiation: gstdiscoverer.c:g_steal_pointer
Unexecuted instantiation: gstdiscoverer-types.c:g_steal_pointer
Unexecuted instantiation: video-enumtypes.c:g_steal_pointer
Unexecuted instantiation: colorbalance.c:g_steal_pointer
Unexecuted instantiation: colorbalancechannel.c:g_steal_pointer
Unexecuted instantiation: convertframe.c:g_steal_pointer
Unexecuted instantiation: gstvideoaffinetransformationmeta.c:g_steal_pointer
Unexecuted instantiation: gstvideocodecalphameta.c:g_steal_pointer
Unexecuted instantiation: gstvideoaggregator.c:g_steal_pointer
Unexecuted instantiation: gstvideodecoder.c:g_steal_pointer
Unexecuted instantiation: gstvideodmabufpool.c:g_steal_pointer
Unexecuted instantiation: gstvideoencoder.c:g_steal_pointer
Unexecuted instantiation: gstvideofilter.c:g_steal_pointer
Unexecuted instantiation: gstvideometa.c:g_steal_pointer
Unexecuted instantiation: gstvideopool.c:g_steal_pointer
Unexecuted instantiation: gstvideosink.c:g_steal_pointer
Unexecuted instantiation: gstvideotimecode.c:g_steal_pointer
Unexecuted instantiation: gstvideoutils.c:g_steal_pointer
Unexecuted instantiation: gstvideoutilsprivate.c:g_steal_pointer
Unexecuted instantiation: navigation.c:g_steal_pointer
Unexecuted instantiation: video.c:g_steal_pointer
Unexecuted instantiation: video-anc.c:g_steal_pointer
Unexecuted instantiation: video-blend.c:g_steal_pointer
Unexecuted instantiation: video-chroma.c:g_steal_pointer
Unexecuted instantiation: video-color.c:g_steal_pointer
Unexecuted instantiation: video-converter.c:g_steal_pointer
Unexecuted instantiation: video-dither.c:g_steal_pointer
Unexecuted instantiation: video-event.c:g_steal_pointer
Unexecuted instantiation: video-format.c:g_steal_pointer
Unexecuted instantiation: video-frame.c:g_steal_pointer
Unexecuted instantiation: video-hdr.c:g_steal_pointer
Unexecuted instantiation: video-info.c:g_steal_pointer
Unexecuted instantiation: video-info-dma.c:g_steal_pointer
Unexecuted instantiation: video-multiview.c:g_steal_pointer
Unexecuted instantiation: video-resampler.c:g_steal_pointer
Unexecuted instantiation: video-scaler.c:g_steal_pointer
Unexecuted instantiation: video-sei.c:g_steal_pointer
Unexecuted instantiation: video-tile.c:g_steal_pointer
Unexecuted instantiation: video-overlay-composition.c:g_steal_pointer
Unexecuted instantiation: videodirection.c:g_steal_pointer
Unexecuted instantiation: videoorientation.c:g_steal_pointer
Unexecuted instantiation: videooverlay.c:g_steal_pointer
Unexecuted instantiation: video-orc.c:g_steal_pointer
Unexecuted instantiation: gstdrmdumb.c:g_steal_pointer
Unexecuted instantiation: gstdmabuf.c:g_steal_pointer
Unexecuted instantiation: gstfdmemory.c:g_steal_pointer
Unexecuted instantiation: gstphysmemory.c:g_steal_pointer
Unexecuted instantiation: gstshmallocator.c:g_steal_pointer
Unexecuted instantiation: gstudmabufallocator.c:g_steal_pointer
Unexecuted instantiation: gstadapter.c:g_steal_pointer
Unexecuted instantiation: gstaggregator.c:g_steal_pointer
Unexecuted instantiation: gstbaseparse.c:g_steal_pointer
Unexecuted instantiation: gstbasesink.c:g_steal_pointer
Unexecuted instantiation: gstbasesrc.c:g_steal_pointer
Unexecuted instantiation: gstbasetransform.c:g_steal_pointer
Unexecuted instantiation: gstbitreader.c:g_steal_pointer
Unexecuted instantiation: gstbitwriter.c:g_steal_pointer
Unexecuted instantiation: gstbytereader.c:g_steal_pointer
Unexecuted instantiation: gstbytewriter.c:g_steal_pointer
Unexecuted instantiation: gstcollectpads.c:g_steal_pointer
Unexecuted instantiation: gstdataqueue.c:g_steal_pointer
Unexecuted instantiation: gstflowcombiner.c:g_steal_pointer
Unexecuted instantiation: gstpushsrc.c:g_steal_pointer
Unexecuted instantiation: gstqueuearray.c:g_steal_pointer
Unexecuted instantiation: gsttypefindhelper.c:g_steal_pointer
Unexecuted instantiation: audio-enumtypes.c:g_steal_pointer
Unexecuted instantiation: audio.c:g_steal_pointer
Unexecuted instantiation: audio-buffer.c:g_steal_pointer
Unexecuted instantiation: audio-channel-mixer.c:g_steal_pointer
Unexecuted instantiation: audio-channels.c:g_steal_pointer
Unexecuted instantiation: audio-converter.c:g_steal_pointer
Unexecuted instantiation: audio-format.c:g_steal_pointer
Unexecuted instantiation: audio-info.c:g_steal_pointer
Unexecuted instantiation: audio-quantize.c:g_steal_pointer
Unexecuted instantiation: audio-resampler.c:g_steal_pointer
Unexecuted instantiation: gstaudioaggregator.c:g_steal_pointer
Unexecuted instantiation: gstaudiobasesink.c:g_steal_pointer
Unexecuted instantiation: gstaudiobasesrc.c:g_steal_pointer
Unexecuted instantiation: gstaudiocdsrc.c:g_steal_pointer
Unexecuted instantiation: gstaudioclock.c:g_steal_pointer
Unexecuted instantiation: gstaudiodecoder.c:g_steal_pointer
Unexecuted instantiation: gstaudioencoder.c:g_steal_pointer
Unexecuted instantiation: gstaudiofilter.c:g_steal_pointer
Unexecuted instantiation: gstaudioiec61937.c:g_steal_pointer
Unexecuted instantiation: gstaudiometa.c:g_steal_pointer
Unexecuted instantiation: gstaudioringbuffer.c:g_steal_pointer
Unexecuted instantiation: gstaudiosink.c:g_steal_pointer
Unexecuted instantiation: gstaudiosrc.c:g_steal_pointer
Unexecuted instantiation: gstaudioutilsprivate.c:g_steal_pointer
Unexecuted instantiation: streamvolume.c:g_steal_pointer
Unexecuted instantiation: gstaudiostreamalign.c:g_steal_pointer
Unexecuted instantiation: gstdsd.c:g_steal_pointer
Unexecuted instantiation: gstdsdformat.c:g_steal_pointer
Unexecuted instantiation: gstaudiopack.c:g_steal_pointer
Unexecuted instantiation: audio-resampler-x86-sse.c:g_steal_pointer
Unexecuted instantiation: audio-resampler-x86-sse2.c:g_steal_pointer
Unexecuted instantiation: audio-resampler-x86-sse41.c:g_steal_pointer
Unexecuted instantiation: tag-enumtypes.c:g_steal_pointer
Unexecuted instantiation: gstvorbistag.c:g_steal_pointer
Unexecuted instantiation: gstid3tag.c:g_steal_pointer
Unexecuted instantiation: gstxmptag.c:g_steal_pointer
Unexecuted instantiation: gstexiftag.c:g_steal_pointer
Unexecuted instantiation: lang.c:g_steal_pointer
Unexecuted instantiation: licenses.c:g_steal_pointer
Unexecuted instantiation: tags.c:g_steal_pointer
Unexecuted instantiation: gsttagdemux.c:g_steal_pointer
Unexecuted instantiation: gsttagmux.c:g_steal_pointer
Unexecuted instantiation: gsttageditingprivate.c:g_steal_pointer
Unexecuted instantiation: id3v2.c:g_steal_pointer
Unexecuted instantiation: id3v2frames.c:g_steal_pointer
Unexecuted instantiation: xmpwriter.c:g_steal_pointer
247
248
/* type safety */
249
#if defined(glib_typeof) && GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_58
250
684k
#define g_steal_pointer(pp) ((glib_typeof (*pp)) (g_steal_pointer) (pp))
251
#else  /* __GNUC__ */
252
/* This version does not depend on gcc extensions, but gcc does not warn
253
 * about incompatible-pointer-types: */
254
#define g_steal_pointer(pp) \
255
  (0 ? (*(pp)) : (g_steal_pointer) (pp))
256
#endif /* __GNUC__ */
257
258
/* Optimise: avoid the call to the (slower) _n function if we can
259
 * determine at compile-time that no overflow happens.
260
 */
261
#if defined (__GNUC__) && (__GNUC__ >= 2) && defined (__OPTIMIZE__)
262
#  define _G_NEW(struct_type, n_structs, func) \
263
59.3M
  (struct_type *) (G_GNUC_EXTENSION ({     \
264
59.3M
    gsize __n = (gsize) (n_structs);      \
265
59.3M
    gsize __s = sizeof (struct_type);     \
266
59.3M
    gpointer __p;           \
267
59.3M
    if (__s == 1)           \
268
59.3M
      __p = g_##func (__n);       \
269
59.3M
    else if (__builtin_constant_p (__n) &&   \
270
1.70M
             (__s == 0 || __n <= G_MAXSIZE / __s)) \
271
1.70M
      __p = g_##func (__n * __s);       \
272
1.70M
    else              \
273
1.70M
      __p = g_##func##_n (__n, __s);     \
274
59.3M
    __p;              \
275
59.3M
  }))
276
#  define _G_RENEW(struct_type, mem, n_structs, func) \
277
106k
  (struct_type *) (G_GNUC_EXTENSION ({     \
278
106k
    gsize __n = (gsize) (n_structs);      \
279
106k
    gsize __s = sizeof (struct_type);     \
280
106k
    gpointer __p = (gpointer) (mem);      \
281
106k
    if (__s == 1)           \
282
106k
      __p = g_##func (__p, __n);       \
283
106k
    else if (__builtin_constant_p (__n) &&   \
284
106k
             (__s == 0 || __n <= G_MAXSIZE / __s)) \
285
106k
      __p = g_##func (__p, __n * __s);     \
286
106k
    else              \
287
106k
      __p = g_##func##_n (__p, __n, __s);     \
288
106k
    __p;              \
289
106k
  }))
290
291
#else
292
293
/* Unoptimised version: always call the _n() function. */
294
295
#define _G_NEW(struct_type, n_structs, func) \
296
        ((struct_type *) g_##func##_n ((n_structs), sizeof (struct_type)))
297
#define _G_RENEW(struct_type, mem, n_structs, func) \
298
        ((struct_type *) g_##func##_n (mem, (n_structs), sizeof (struct_type)))
299
300
#endif
301
302
/**
303
 * g_new:
304
 * @struct_type: the type of the elements to allocate
305
 * @n_structs: the number of elements to allocate
306
 * 
307
 * Allocates @n_structs elements of type @struct_type.
308
 * The returned pointer is cast to a pointer to the given type.
309
 * If @n_structs is 0 it returns %NULL.
310
 * Care is taken to avoid overflow when calculating the size of the allocated block.
311
 * 
312
 * Since the returned pointer is already casted to the right type,
313
 * it is normally unnecessary to cast it explicitly, and doing
314
 * so might hide memory allocation errors.
315
 * 
316
 * Returns: a pointer to the allocated memory, cast to a pointer to @struct_type
317
 */
318
57.9M
#define g_new(struct_type, n_structs)     _G_NEW (struct_type, n_structs, malloc)
319
/**
320
 * g_new0:
321
 * @struct_type: the type of the elements to allocate.
322
 * @n_structs: the number of elements to allocate.
323
 * 
324
 * Allocates @n_structs elements of type @struct_type, initialized to 0's.
325
 * The returned pointer is cast to a pointer to the given type.
326
 * If @n_structs is 0 it returns %NULL.
327
 * Care is taken to avoid overflow when calculating the size of the allocated block.
328
 * 
329
 * Since the returned pointer is already casted to the right type,
330
 * it is normally unnecessary to cast it explicitly, and doing
331
 * so might hide memory allocation errors.
332
 * 
333
 * Returns: a pointer to the allocated memory, cast to a pointer to @struct_type.
334
 */
335
1.33M
#define g_new0(struct_type, n_structs)      _G_NEW (struct_type, n_structs, malloc0)
336
/**
337
 * g_renew:
338
 * @struct_type: the type of the elements to allocate
339
 * @mem: the currently allocated memory
340
 * @n_structs: the number of elements to allocate
341
 * 
342
 * Reallocates the memory pointed to by @mem, so that it now has space for
343
 * @n_structs elements of type @struct_type. It returns the new address of
344
 * the memory, which may have been moved.
345
 * Care is taken to avoid overflow when calculating the size of the allocated block.
346
 * 
347
 * Returns: a pointer to the new allocated memory, cast to a pointer to @struct_type
348
 */
349
106k
#define g_renew(struct_type, mem, n_structs)    _G_RENEW (struct_type, mem, n_structs, realloc)
350
/**
351
 * g_try_new:
352
 * @struct_type: the type of the elements to allocate
353
 * @n_structs: the number of elements to allocate
354
 * 
355
 * Attempts to allocate @n_structs elements of type @struct_type, and returns
356
 * %NULL on failure. Contrast with g_new(), which aborts the program on failure.
357
 * The returned pointer is cast to a pointer to the given type.
358
 * The function returns %NULL when @n_structs is 0 of if an overflow occurs.
359
 * 
360
 * Since: 2.8
361
 * Returns: a pointer to the allocated memory, cast to a pointer to @struct_type
362
 */
363
0
#define g_try_new(struct_type, n_structs)   _G_NEW (struct_type, n_structs, try_malloc)
364
/**
365
 * g_try_new0:
366
 * @struct_type: the type of the elements to allocate
367
 * @n_structs: the number of elements to allocate
368
 * 
369
 * Attempts to allocate @n_structs elements of type @struct_type, initialized
370
 * to 0's, and returns %NULL on failure. Contrast with g_new0(), which aborts
371
 * the program on failure.
372
 * The returned pointer is cast to a pointer to the given type.
373
 * The function returns %NULL when @n_structs is 0 or if an overflow occurs.
374
 * 
375
 * Since: 2.8
376
 * Returns: a pointer to the allocated memory, cast to a pointer to @struct_type
377
 */
378
#define g_try_new0(struct_type, n_structs)    _G_NEW (struct_type, n_structs, try_malloc0)
379
/**
380
 * g_try_renew:
381
 * @struct_type: the type of the elements to allocate
382
 * @mem: the currently allocated memory
383
 * @n_structs: the number of elements to allocate
384
 * 
385
 * Attempts to reallocate the memory pointed to by @mem, so that it now has
386
 * space for @n_structs elements of type @struct_type, and returns %NULL on
387
 * failure. Contrast with g_renew(), which aborts the program on failure.
388
 * It returns the new address of the memory, which may have been moved.
389
 * The function returns %NULL if an overflow occurs.
390
 * 
391
 * Since: 2.8
392
 * Returns: a pointer to the new allocated memory, cast to a pointer to @struct_type
393
 */
394
#define g_try_renew(struct_type, mem, n_structs)  _G_RENEW (struct_type, mem, n_structs, try_realloc)
395
396
397
/* Memory allocation virtualization for debugging purposes
398
 * g_mem_set_vtable() has to be the very first GLib function called
399
 * if being used
400
 */
401
struct _GMemVTable {
402
  gpointer (*malloc)      (gsize    n_bytes);
403
  gpointer (*realloc)     (gpointer mem,
404
         gsize    n_bytes);
405
  void     (*free)        (gpointer mem);
406
  /* optional; set to NULL if not used ! */
407
  gpointer (*calloc)      (gsize    n_blocks,
408
         gsize    n_block_bytes);
409
  gpointer (*try_malloc)  (gsize    n_bytes);
410
  gpointer (*try_realloc) (gpointer mem,
411
         gsize    n_bytes);
412
};
413
GLIB_DEPRECATED_IN_2_46
414
void   g_mem_set_vtable (GMemVTable *vtable);
415
GLIB_DEPRECATED_IN_2_46
416
gboolean g_mem_is_system_malloc (void);
417
418
GLIB_VAR gboolean g_mem_gc_friendly;
419
420
/* Memory profiler and checker, has to be enabled via g_mem_set_vtable()
421
 */
422
GLIB_VAR GMemVTable *glib_mem_profiler_table;
423
GLIB_DEPRECATED_IN_2_46
424
void  g_mem_profile (void);
425
426
G_END_DECLS
427
428
#endif /* __G_MEM_H__ */