Coverage Report

Created: 2025-07-12 06:30

/src/tinysparql/subprojects/glib-2.80.3/glib/gmem.h
Line
Count
Source (jump to first uncovered line)
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
89.2k
  G_STMT_START                                           \
137
89.2k
  {                                                      \
138
89.2k
    G_STATIC_ASSERT (sizeof *(pp) == sizeof (gpointer)); \
139
89.2k
    glib_typeof ((pp)) _pp = (pp);                       \
140
89.2k
    glib_typeof (*(pp)) _ptr = *_pp;                     \
141
89.2k
    *_pp = NULL;                                         \
142
89.2k
    if (_ptr)                                            \
143
89.2k
      (destroy) (_ptr);                                  \
144
89.2k
  }                                                      \
145
89.2k
  G_STMT_END                                             \
146
134
  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
234
g_steal_pointer (gpointer pp)
235
21.8k
{
236
21.8k
  gpointer *ptr = (gpointer *) pp;
237
21.8k
  gpointer ref;
238
239
21.8k
  ref = *ptr;
240
21.8k
  *ptr = NULL;
241
242
21.8k
  return ref;
243
21.8k
}
Unexecuted instantiation: fuzz_query.c:g_steal_pointer
Unexecuted instantiation: gfile.c:g_steal_pointer
Unexecuted instantiation: gfileattribute.c:g_steal_pointer
Unexecuted instantiation: gfileinfo.c:g_steal_pointer
Unexecuted instantiation: gfileinputstream.c:g_steal_pointer
Unexecuted instantiation: gfileoutputstream.c:g_steal_pointer
Unexecuted instantiation: gicon.c:g_steal_pointer
Unexecuted instantiation: ginputstream.c:g_steal_pointer
Unexecuted instantiation: gioerror.c:g_steal_pointer
Unexecuted instantiation: goutputstream.c:g_steal_pointer
Unexecuted instantiation: gpollableinputstream.c:g_steal_pointer
Unexecuted instantiation: gpollableoutputstream.c:g_steal_pointer
Unexecuted instantiation: gpollfilemonitor.c:g_steal_pointer
Unexecuted instantiation: gresource.c:g_steal_pointer
Unexecuted instantiation: gseekable.c:g_steal_pointer
Unexecuted instantiation: gtask.c:g_steal_pointer
Unexecuted instantiation: gthemedicon.c:g_steal_pointer
gvfs.c:g_steal_pointer
Line
Count
Source
235
3
{
236
3
  gpointer *ptr = (gpointer *) pp;
237
3
  gpointer ref;
238
239
3
  ref = *ptr;
240
3
  *ptr = NULL;
241
242
3
  return ref;
243
3
}
Unexecuted instantiation: gzlibdecompressor.c:g_steal_pointer
Unexecuted instantiation: gfiledescriptorbased.c:g_steal_pointer
Unexecuted instantiation: gdesktopappinfo.c:g_steal_pointer
Unexecuted instantiation: gdbusutils.c:g_steal_pointer
Unexecuted instantiation: gdbuserror.c:g_steal_pointer
Unexecuted instantiation: gdbusconnection.c:g_steal_pointer
Unexecuted instantiation: gdbusmessage.c:g_steal_pointer
Unexecuted instantiation: gdbusprivate.c:g_steal_pointer
Unexecuted instantiation: gdbusintrospection.c:g_steal_pointer
Unexecuted instantiation: gdbusmethodinvocation.c:g_steal_pointer
Unexecuted instantiation: gdocumentportal.c:g_steal_pointer
Unexecuted instantiation: glocalfile.c:g_steal_pointer
Unexecuted instantiation: glocalfileenumerator.c:g_steal_pointer
Unexecuted instantiation: glocalfileinfo.c:g_steal_pointer
Unexecuted instantiation: glocalfileinputstream.c:g_steal_pointer
Unexecuted instantiation: glocalfilemonitor.c:g_steal_pointer
Unexecuted instantiation: glocalfileoutputstream.c:g_steal_pointer
Unexecuted instantiation: glocalfileiostream.c:g_steal_pointer
Unexecuted instantiation: glocalvfs.c:g_steal_pointer
Unexecuted instantiation: thumbnail-verify.c:g_steal_pointer
Unexecuted instantiation: gvdb-reader.c:g_steal_pointer
Unexecuted instantiation: gioenumtypes.c:g_steal_pointer
Unexecuted instantiation: xdp-dbus.c:g_steal_pointer
Unexecuted instantiation: gappinfo.c:g_steal_pointer
Unexecuted instantiation: gasyncinitable.c:g_steal_pointer
Unexecuted instantiation: gasyncresult.c:g_steal_pointer
Unexecuted instantiation: gbytesicon.c:g_steal_pointer
Unexecuted instantiation: gcancellable.c:g_steal_pointer
Unexecuted instantiation: gcontextspecificgroup.c:g_steal_pointer
Unexecuted instantiation: gconverter.c:g_steal_pointer
Unexecuted instantiation: gconverterinputstream.c:g_steal_pointer
Unexecuted instantiation: gdummyfile.c:g_steal_pointer
Unexecuted instantiation: gemblem.c:g_steal_pointer
Unexecuted instantiation: gemblemedicon.c:g_steal_pointer
Unexecuted instantiation: gfileenumerator.c:g_steal_pointer
Unexecuted instantiation: gfileicon.c:g_steal_pointer
Unexecuted instantiation: gfilemonitor.c:g_steal_pointer
Unexecuted instantiation: gfileiostream.c:g_steal_pointer
Unexecuted instantiation: gfilterinputstream.c:g_steal_pointer
Unexecuted instantiation: ginitable.c:g_steal_pointer
giomodule.c:g_steal_pointer
Line
Count
Source
235
2
{
236
2
  gpointer *ptr = (gpointer *) pp;
237
2
  gpointer ref;
238
239
2
  ref = *ptr;
240
2
  *ptr = NULL;
241
242
2
  return ref;
243
2
}
Unexecuted instantiation: giomodule-priv.c:g_steal_pointer
Unexecuted instantiation: giostream.c:g_steal_pointer
Unexecuted instantiation: gloadableicon.c:g_steal_pointer
Unexecuted instantiation: gmarshal-internal.c:g_steal_pointer
Unexecuted instantiation: gmemorymonitor.c:g_steal_pointer
Unexecuted instantiation: gmemorymonitordbus.c:g_steal_pointer
Unexecuted instantiation: gmemoryinputstream.c:g_steal_pointer
Unexecuted instantiation: gnativevolumemonitor.c:g_steal_pointer
Unexecuted instantiation: gnetworkmonitor.c:g_steal_pointer
Unexecuted instantiation: gnetworkmonitorbase.c:g_steal_pointer
Unexecuted instantiation: gpollableutils.c:g_steal_pointer
Unexecuted instantiation: gpowerprofilemonitor.c:g_steal_pointer
Unexecuted instantiation: gpowerprofilemonitordbus.c:g_steal_pointer
Unexecuted instantiation: gproxy.c:g_steal_pointer
Unexecuted instantiation: gproxyresolver.c:g_steal_pointer
Unexecuted instantiation: gresourcefile.c:g_steal_pointer
Unexecuted instantiation: gsimpleasyncresult.c:g_steal_pointer
Unexecuted instantiation: gsocket.c:g_steal_pointer
Unexecuted instantiation: gsocketaddress.c:g_steal_pointer
Unexecuted instantiation: gsocketaddressenumerator.c:g_steal_pointer
Unexecuted instantiation: gsocketconnectable.c:g_steal_pointer
Unexecuted instantiation: gsocketconnection.c:g_steal_pointer
Unexecuted instantiation: gsocketcontrolmessage.c:g_steal_pointer
Unexecuted instantiation: gsocketinputstream.c:g_steal_pointer
Unexecuted instantiation: gsocketoutputstream.c:g_steal_pointer
Unexecuted instantiation: gtcpconnection.c:g_steal_pointer
Unexecuted instantiation: gtlsbackend.c:g_steal_pointer
Unexecuted instantiation: gtlsdatabase.c:g_steal_pointer
Unexecuted instantiation: gtlsinteraction.c:g_steal_pointer
Unexecuted instantiation: gtlspassword.c:g_steal_pointer
Unexecuted instantiation: gunionvolumemonitor.c:g_steal_pointer
Unexecuted instantiation: gunixconnection.c:g_steal_pointer
Unexecuted instantiation: gunixfdlist.c:g_steal_pointer
Unexecuted instantiation: gunixcredentialsmessage.c:g_steal_pointer
Unexecuted instantiation: gunixsocketaddress.c:g_steal_pointer
Unexecuted instantiation: gvolumemonitor.c:g_steal_pointer
Unexecuted instantiation: gcontenttype.c:g_steal_pointer
Unexecuted instantiation: gunixfdmessage.c:g_steal_pointer
Unexecuted instantiation: gunixmounts.c:g_steal_pointer
Unexecuted instantiation: gunixvolumemonitor.c:g_steal_pointer
Unexecuted instantiation: gfdonotificationbackend.c:g_steal_pointer
Unexecuted instantiation: ggtknotificationbackend.c:g_steal_pointer
Unexecuted instantiation: gnetworkmonitornetlink.c:g_steal_pointer
Unexecuted instantiation: gnetworkmonitornm.c:g_steal_pointer
Unexecuted instantiation: gapplication.c:g_steal_pointer
Unexecuted instantiation: gapplicationcommandline.c:g_steal_pointer
Unexecuted instantiation: gapplicationimpl-dbus.c:g_steal_pointer
Unexecuted instantiation: gactiongroup.c:g_steal_pointer
Unexecuted instantiation: gactionmap.c:g_steal_pointer
Unexecuted instantiation: gsimpleactiongroup.c:g_steal_pointer
Unexecuted instantiation: gremoteactiongroup.c:g_steal_pointer
Unexecuted instantiation: gactiongroupexporter.c:g_steal_pointer
Unexecuted instantiation: gdbusactiongroup.c:g_steal_pointer
Unexecuted instantiation: gaction.c:g_steal_pointer
Unexecuted instantiation: gsimpleaction.c:g_steal_pointer
Unexecuted instantiation: gnotification.c:g_steal_pointer
Unexecuted instantiation: gnotificationbackend.c:g_steal_pointer
Unexecuted instantiation: gkeyfilesettingsbackend.c:g_steal_pointer
Unexecuted instantiation: gmemorysettingsbackend.c:g_steal_pointer
Unexecuted instantiation: gnullsettingsbackend.c:g_steal_pointer
Unexecuted instantiation: gsettingsbackend.c:g_steal_pointer
Unexecuted instantiation: gsettings.c:g_steal_pointer
Unexecuted instantiation: gdbusaddress.c:g_steal_pointer
Unexecuted instantiation: gdbusauthobserver.c:g_steal_pointer
Unexecuted instantiation: gdbusauth.c:g_steal_pointer
Unexecuted instantiation: gdbusauthmechanism.c:g_steal_pointer
Unexecuted instantiation: gdbusauthmechanismanon.c:g_steal_pointer
Unexecuted instantiation: gdbusauthmechanismexternal.c:g_steal_pointer
Unexecuted instantiation: gdbusauthmechanismsha1.c:g_steal_pointer
Unexecuted instantiation: gdbusnamewatching.c:g_steal_pointer
Unexecuted instantiation: gdbusproxy.c:g_steal_pointer
Unexecuted instantiation: gdbusinterface.c:g_steal_pointer
Unexecuted instantiation: gdbusinterfaceskeleton.c:g_steal_pointer
Unexecuted instantiation: gdbusobject.c:g_steal_pointer
Unexecuted instantiation: gdbusobjectskeleton.c:g_steal_pointer
Unexecuted instantiation: gopenuriportal.c:g_steal_pointer
Unexecuted instantiation: gmemorymonitorportal.c:g_steal_pointer
Unexecuted instantiation: gnetworkmonitorportal.c:g_steal_pointer
Unexecuted instantiation: gpowerprofilemonitorportal.c:g_steal_pointer
Unexecuted instantiation: gproxyresolverportal.c:g_steal_pointer
Unexecuted instantiation: gtrashportal.c:g_steal_pointer
Unexecuted instantiation: gportalsupport.c:g_steal_pointer
Unexecuted instantiation: gportalnotificationbackend.c:g_steal_pointer
Unexecuted instantiation: gsandbox.c:g_steal_pointer
Unexecuted instantiation: ghttpproxy.c:g_steal_pointer
Unexecuted instantiation: gsocks4proxy.c:g_steal_pointer
Unexecuted instantiation: gsocks4aproxy.c:g_steal_pointer
Unexecuted instantiation: gsocks5proxy.c:g_steal_pointer
Unexecuted instantiation: ginotifyfilemonitor.c:g_steal_pointer
Unexecuted instantiation: gcredentials.c:g_steal_pointer
Unexecuted instantiation: gdatagrambased.c:g_steal_pointer
Unexecuted instantiation: gdatainputstream.c:g_steal_pointer
Unexecuted instantiation: gdataoutputstream.c:g_steal_pointer
Unexecuted instantiation: gdebugcontroller.c:g_steal_pointer
Unexecuted instantiation: gdebugcontrollerdbus.c:g_steal_pointer
Unexecuted instantiation: gdrive.c:g_steal_pointer
Unexecuted instantiation: gdummyproxyresolver.c:g_steal_pointer
Unexecuted instantiation: gdummytlsbackend.c:g_steal_pointer
Unexecuted instantiation: gfilteroutputstream.c:g_steal_pointer
Unexecuted instantiation: ginetaddress.c:g_steal_pointer
Unexecuted instantiation: ginetaddressmask.c:g_steal_pointer
Unexecuted instantiation: ginetsocketaddress.c:g_steal_pointer
Unexecuted instantiation: gioscheduler.c:g_steal_pointer
Unexecuted instantiation: gmount.c:g_steal_pointer
Unexecuted instantiation: gnativesocketaddress.c:g_steal_pointer
Unexecuted instantiation: gnetworkaddress.c:g_steal_pointer
Unexecuted instantiation: gnetworking.c:g_steal_pointer
Unexecuted instantiation: gproxyaddress.c:g_steal_pointer
Unexecuted instantiation: gproxyaddressenumerator.c:g_steal_pointer
Unexecuted instantiation: gresolver.c:g_steal_pointer
Unexecuted instantiation: gsimplepermission.c:g_steal_pointer
Unexecuted instantiation: gsocketclient.c:g_steal_pointer
Unexecuted instantiation: gsrvtarget.c:g_steal_pointer
Unexecuted instantiation: gtcpwrapperconnection.c:g_steal_pointer
Unexecuted instantiation: gthreadedresolver.c:g_steal_pointer
Unexecuted instantiation: gtlscertificate.c:g_steal_pointer
Unexecuted instantiation: gtlsclientconnection.c:g_steal_pointer
Unexecuted instantiation: gtlsconnection.c:g_steal_pointer
Unexecuted instantiation: gtlsfiledatabase.c:g_steal_pointer
Unexecuted instantiation: gtlsserverconnection.c:g_steal_pointer
Unexecuted instantiation: gdtlsconnection.c:g_steal_pointer
Unexecuted instantiation: gdtlsclientconnection.c:g_steal_pointer
Unexecuted instantiation: gdtlsserverconnection.c:g_steal_pointer
Unexecuted instantiation: gvolume.c:g_steal_pointer
Unexecuted instantiation: gunixmount.c:g_steal_pointer
Unexecuted instantiation: gunixvolume.c:g_steal_pointer
Unexecuted instantiation: gunixinputstream.c:g_steal_pointer
Unexecuted instantiation: gdelayedsettingsbackend.c:g_steal_pointer
Unexecuted instantiation: gsettingsschema.c:g_steal_pointer
Unexecuted instantiation: gsettings-mapping.c:g_steal_pointer
Unexecuted instantiation: inotify-sub.c:g_steal_pointer
Unexecuted instantiation: inotify-helper.c:g_steal_pointer
Unexecuted instantiation: gbufferedinputstream.c:g_steal_pointer
Unexecuted instantiation: gnetworkservice.c:g_steal_pointer
Unexecuted instantiation: gpermission.c:g_steal_pointer
Unexecuted instantiation: gsubprocess.c:g_steal_pointer
Unexecuted instantiation: giounix-private.c:g_steal_pointer
Unexecuted instantiation: gunixoutputstream.c:g_steal_pointer
Unexecuted instantiation: inotify-path.c:g_steal_pointer
Unexecuted instantiation: inotify-missing.c:g_steal_pointer
Unexecuted instantiation: gmemoryoutputstream.c:g_steal_pointer
Unexecuted instantiation: inotify-kernel.c:g_steal_pointer
garray.c:g_steal_pointer
Line
Count
Source
235
21.7k
{
236
21.7k
  gpointer *ptr = (gpointer *) pp;
237
21.7k
  gpointer ref;
238
239
21.7k
  ref = *ptr;
240
21.7k
  *ptr = NULL;
241
242
21.7k
  return ref;
243
21.7k
}
Unexecuted instantiation: gbase64.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: 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
235
132
{
236
132
  gpointer *ptr = (gpointer *) pp;
237
132
  gpointer ref;
238
239
132
  ref = *ptr;
240
132
  *ptr = NULL;
241
242
132
  return ref;
243
132
}
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: goption.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: grefcount.c:g_steal_pointer
Unexecuted instantiation: gregex.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: gstdio.c:g_steal_pointer
Unexecuted instantiation: gstrfuncs.c:g_steal_pointer
Unexecuted instantiation: gstring.c:g_steal_pointer
Unexecuted instantiation: gtestutils.c:g_steal_pointer
gthread.c:g_steal_pointer
Line
Count
Source
235
2
{
236
2
  gpointer *ptr = (gpointer *) pp;
237
2
  gpointer ref;
238
239
2
  ref = *ptr;
240
2
  *ptr = NULL;
241
242
2
  return ref;
243
2
}
Unexecuted instantiation: gthreadpool.c:g_steal_pointer
Unexecuted instantiation: gtimer.c:g_steal_pointer
gtimezone.c:g_steal_pointer
Line
Count
Source
235
6
{
236
6
  gpointer *ptr = (gpointer *) pp;
237
6
  gpointer ref;
238
239
6
  ref = *ptr;
240
6
  *ptr = NULL;
241
242
6
  return ref;
243
6
}
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
Unexecuted instantiation: gutils.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: gprintf.c:g_steal_pointer
Unexecuted instantiation: glib-unix.c:g_steal_pointer
Unexecuted instantiation: gspawn.c:g_steal_pointer
Unexecuted instantiation: giounix.c:g_steal_pointer
Unexecuted instantiation: gthread-posix.c:g_steal_pointer
Unexecuted instantiation: garcbox.c:g_steal_pointer
Unexecuted instantiation: gasyncqueue.c:g_steal_pointer
Unexecuted instantiation: gbitlock.c:g_steal_pointer
Unexecuted instantiation: gdate.c:g_steal_pointer
Unexecuted instantiation: grcbox.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
235
21
{
236
21
  gpointer *ptr = (gpointer *) pp;
237
21
  gpointer ref;
238
239
21
  ref = *ptr;
240
21
  *ptr = NULL;
241
242
21
  return ref;
243
21
}
Unexecuted instantiation: gparam.c:g_steal_pointer
Unexecuted instantiation: gparamspecs.c:g_steal_pointer
Unexecuted instantiation: gsignal.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: gatomicarray.c:g_steal_pointer
Unexecuted instantiation: gmodule.c:g_steal_pointer
Unexecuted instantiation: gmodule-deprecated.c:g_steal_pointer
Unexecuted instantiation: tracker-connection.c:g_steal_pointer
Unexecuted instantiation: tracker-cursor.c:g_steal_pointer
Unexecuted instantiation: tracker-error.c:g_steal_pointer
Unexecuted instantiation: tracker-namespace-manager.c:g_steal_pointer
Unexecuted instantiation: tracker-resource.c:g_steal_pointer
Unexecuted instantiation: tracker-serializer.c:g_steal_pointer
Unexecuted instantiation: tracker-serializer-json.c:g_steal_pointer
Unexecuted instantiation: tracker-serializer-json-ld.c:g_steal_pointer
Unexecuted instantiation: tracker-serializer-trig.c:g_steal_pointer
Unexecuted instantiation: tracker-serializer-turtle.c:g_steal_pointer
Unexecuted instantiation: tracker-serializer-xml.c:g_steal_pointer
Unexecuted instantiation: tracker-uri.c:g_steal_pointer
Unexecuted instantiation: tracker-utils.c:g_steal_pointer
Unexecuted instantiation: tracker-data-manager.c:g_steal_pointer
Unexecuted instantiation: tracker-data-query.c:g_steal_pointer
Unexecuted instantiation: tracker-data-update.c:g_steal_pointer
Unexecuted instantiation: tracker-db-interface.c:g_steal_pointer
Unexecuted instantiation: tracker-db-interface-sqlite.c:g_steal_pointer
Unexecuted instantiation: tracker-db-manager.c:g_steal_pointer
Unexecuted instantiation: tracker-fts-tokenizer.c:g_steal_pointer
Unexecuted instantiation: tracker-namespace.c:g_steal_pointer
Unexecuted instantiation: tracker-ontologies.c:g_steal_pointer
Unexecuted instantiation: tracker-ontologies-diff.c:g_steal_pointer
Unexecuted instantiation: tracker-ontologies-introspect.c:g_steal_pointer
Unexecuted instantiation: tracker-ontologies-rdf.c:g_steal_pointer
Unexecuted instantiation: tracker-property.c:g_steal_pointer
Unexecuted instantiation: tracker-rowid.c:g_steal_pointer
Unexecuted instantiation: tracker-sparql.c:g_steal_pointer
Unexecuted instantiation: tracker-uuid.c:g_steal_pointer
Unexecuted instantiation: tracker-vtab-service.c:g_steal_pointer
Unexecuted instantiation: tracker-vtab-triples.c:g_steal_pointer
Unexecuted instantiation: tracker-bus.c:g_steal_pointer
Unexecuted instantiation: tracker-bus-batch.c:g_steal_pointer
Unexecuted instantiation: tracker-bus-cursor.c:g_steal_pointer
Unexecuted instantiation: tracker-bus-statement.c:g_steal_pointer
Unexecuted instantiation: tracker-direct.c:g_steal_pointer
Unexecuted instantiation: tracker-direct-batch.c:g_steal_pointer
Unexecuted instantiation: tracker-direct-statement.c:g_steal_pointer
Unexecuted instantiation: tracker-remote.c:g_steal_pointer
Unexecuted instantiation: tracker-sparql-enum-types.c:g_steal_pointer
Unexecuted instantiation: tracker-data-enum-types.c:g_steal_pointer
Unexecuted instantiation: tracker-gresources.c:g_steal_pointer
Unexecuted instantiation: tracker-nepomuk-gresources.c:g_steal_pointer
Unexecuted instantiation: tracker-date-time.c:g_steal_pointer
Unexecuted instantiation: tracker-debug.c:g_steal_pointer
Unexecuted instantiation: tracker-file-utils.c:g_steal_pointer
Unexecuted instantiation: tracker-parser-libunistring.c:g_steal_pointer
Unexecuted instantiation: tracker-http.c:g_steal_pointer
Unexecuted instantiation: tracker-batch.c:g_steal_pointer
Unexecuted instantiation: tracker-deserializer.c:g_steal_pointer
Unexecuted instantiation: tracker-deserializer-turtle.c:g_steal_pointer
Unexecuted instantiation: tracker-deserializer-json.c:g_steal_pointer
Unexecuted instantiation: tracker-deserializer-json-ld.c:g_steal_pointer
Unexecuted instantiation: tracker-deserializer-resource.c:g_steal_pointer
Unexecuted instantiation: tracker-deserializer-xml.c:g_steal_pointer
Unexecuted instantiation: tracker-notifier.c:g_steal_pointer
Unexecuted instantiation: tracker-statement.c:g_steal_pointer
Unexecuted instantiation: tracker-class.c:g_steal_pointer
Unexecuted instantiation: tracker-collation.c:g_steal_pointer
Unexecuted instantiation: tracker-ontology.c:g_steal_pointer
Unexecuted instantiation: tracker-string-builder.c:g_steal_pointer
Unexecuted instantiation: tracker-sparql-parser.c:g_steal_pointer
Unexecuted instantiation: tracker-sparql-types.c:g_steal_pointer
Unexecuted instantiation: tracker-remote-statement.c:g_steal_pointer
Unexecuted instantiation: tracker-remote-namespaces.c:g_steal_pointer
Unexecuted instantiation: tracker-language.c:g_steal_pointer
Unexecuted instantiation: tracker-deserializer-rdf.c:g_steal_pointer
Unexecuted instantiation: json-array.c:g_steal_pointer
Unexecuted instantiation: json-builder.c:g_steal_pointer
Unexecuted instantiation: json-generator.c:g_steal_pointer
Unexecuted instantiation: json-node.c:g_steal_pointer
Unexecuted instantiation: json-object.c:g_steal_pointer
Unexecuted instantiation: json-parser.c:g_steal_pointer
Unexecuted instantiation: json-reader.c:g_steal_pointer
Unexecuted instantiation: json-scanner.c:g_steal_pointer
Unexecuted instantiation: json-value.c:g_steal_pointer
Unexecuted instantiation: json-debug.c:g_steal_pointer
Unexecuted instantiation: gbookmarkfile.c:g_steal_pointer
Unexecuted instantiation: ghmac.c:g_steal_pointer
Unexecuted instantiation: ghook.c:g_steal_pointer
Unexecuted instantiation: gnode.c:g_steal_pointer
Unexecuted instantiation: gscanner.c:g_steal_pointer
Unexecuted instantiation: gstrvbuilder.c:g_steal_pointer
Unexecuted instantiation: guuid.c:g_steal_pointer
244
245
/* type safety */
246
#if defined(glib_typeof) && GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_58
247
21.9k
#define g_steal_pointer(pp) ((glib_typeof (*pp)) (g_steal_pointer) (pp))
248
#else  /* __GNUC__ */
249
/* This version does not depend on gcc extensions, but gcc does not warn
250
 * about incompatible-pointer-types: */
251
#define g_steal_pointer(pp) \
252
  (0 ? (*(pp)) : (g_steal_pointer) (pp))
253
#endif /* __GNUC__ */
254
255
/* Optimise: avoid the call to the (slower) _n function if we can
256
 * determine at compile-time that no overflow happens.
257
 */
258
#if defined (__GNUC__) && (__GNUC__ >= 2) && defined (__OPTIMIZE__)
259
#  define _G_NEW(struct_type, n_structs, func) \
260
822k
  (struct_type *) (G_GNUC_EXTENSION ({     \
261
822k
    gsize __n = (gsize) (n_structs);      \
262
822k
    gsize __s = sizeof (struct_type);     \
263
822k
    gpointer __p;           \
264
822k
    if (__s == 1)           \
265
822k
      __p = g_##func (__n);       \
266
822k
    else if (__builtin_constant_p (__n) &&   \
267
792k
             (__s == 0 || __n <= G_MAXSIZE / __s)) \
268
792k
      __p = g_##func (__n * __s);       \
269
792k
    else              \
270
792k
      __p = g_##func##_n (__n, __s);     \
271
822k
    __p;              \
272
822k
  }))
273
#  define _G_RENEW(struct_type, mem, n_structs, func) \
274
16.1k
  (struct_type *) (G_GNUC_EXTENSION ({     \
275
16.1k
    gsize __n = (gsize) (n_structs);      \
276
16.1k
    gsize __s = sizeof (struct_type);     \
277
16.1k
    gpointer __p = (gpointer) (mem);      \
278
16.1k
    if (__s == 1)           \
279
16.1k
      __p = g_##func (__p, __n);       \
280
16.1k
    else if (__builtin_constant_p (__n) &&   \
281
16.1k
             (__s == 0 || __n <= G_MAXSIZE / __s)) \
282
16.1k
      __p = g_##func (__p, __n * __s);     \
283
16.1k
    else              \
284
16.1k
      __p = g_##func##_n (__p, __n, __s);     \
285
16.1k
    __p;              \
286
16.1k
  }))
287
288
#else
289
290
/* Unoptimised version: always call the _n() function. */
291
292
#define _G_NEW(struct_type, n_structs, func) \
293
        ((struct_type *) g_##func##_n ((n_structs), sizeof (struct_type)))
294
#define _G_RENEW(struct_type, mem, n_structs, func) \
295
        ((struct_type *) g_##func##_n (mem, (n_structs), sizeof (struct_type)))
296
297
#endif
298
299
/**
300
 * g_new:
301
 * @struct_type: the type of the elements to allocate
302
 * @n_structs: the number of elements to allocate
303
 * 
304
 * Allocates @n_structs elements of type @struct_type.
305
 * The returned pointer is cast to a pointer to the given type.
306
 * If @n_structs is 0 it returns %NULL.
307
 * Care is taken to avoid overflow when calculating the size of the allocated block.
308
 * 
309
 * Since the returned pointer is already casted to the right type,
310
 * it is normally unnecessary to cast it explicitly, and doing
311
 * so might hide memory allocation errors.
312
 * 
313
 * Returns: a pointer to the allocated memory, cast to a pointer to @struct_type
314
 */
315
40.6k
#define g_new(struct_type, n_structs)     _G_NEW (struct_type, n_structs, malloc)
316
/**
317
 * g_new0:
318
 * @struct_type: the type of the elements to allocate.
319
 * @n_structs: the number of elements to allocate.
320
 * 
321
 * Allocates @n_structs elements of type @struct_type, initialized to 0's.
322
 * The returned pointer is cast to a pointer to the given type.
323
 * If @n_structs is 0 it returns %NULL.
324
 * Care is taken to avoid overflow when calculating the size of the allocated block.
325
 * 
326
 * Since the returned pointer is already casted to the right type,
327
 * it is normally unnecessary to cast it explicitly, and doing
328
 * so might hide memory allocation errors.
329
 * 
330
 * Returns: a pointer to the allocated memory, cast to a pointer to @struct_type.
331
 */
332
781k
#define g_new0(struct_type, n_structs)      _G_NEW (struct_type, n_structs, malloc0)
333
/**
334
 * g_renew:
335
 * @struct_type: the type of the elements to allocate
336
 * @mem: the currently allocated memory
337
 * @n_structs: the number of elements to allocate
338
 * 
339
 * Reallocates the memory pointed to by @mem, so that it now has space for
340
 * @n_structs elements of type @struct_type. It returns the new address of
341
 * the memory, which may have been moved.
342
 * Care is taken to avoid overflow when calculating the size of the allocated block.
343
 * 
344
 * Returns: a pointer to the new allocated memory, cast to a pointer to @struct_type
345
 */
346
16.1k
#define g_renew(struct_type, mem, n_structs)    _G_RENEW (struct_type, mem, n_structs, realloc)
347
/**
348
 * g_try_new:
349
 * @struct_type: the type of the elements to allocate
350
 * @n_structs: the number of elements to allocate
351
 * 
352
 * Attempts to allocate @n_structs elements of type @struct_type, and returns
353
 * %NULL on failure. Contrast with g_new(), which aborts the program on failure.
354
 * The returned pointer is cast to a pointer to the given type.
355
 * The function returns %NULL when @n_structs is 0 of if an overflow occurs.
356
 * 
357
 * Since: 2.8
358
 * Returns: a pointer to the allocated memory, cast to a pointer to @struct_type
359
 */
360
#define g_try_new(struct_type, n_structs)   _G_NEW (struct_type, n_structs, try_malloc)
361
/**
362
 * g_try_new0:
363
 * @struct_type: the type of the elements to allocate
364
 * @n_structs: the number of elements to allocate
365
 * 
366
 * Attempts to allocate @n_structs elements of type @struct_type, initialized
367
 * to 0's, and returns %NULL on failure. Contrast with g_new0(), which aborts
368
 * the program on failure.
369
 * The returned pointer is cast to a pointer to the given type.
370
 * The function returns %NULL when @n_structs is 0 or if an overflow occurs.
371
 * 
372
 * Since: 2.8
373
 * Returns: a pointer to the allocated memory, cast to a pointer to @struct_type
374
 */
375
#define g_try_new0(struct_type, n_structs)    _G_NEW (struct_type, n_structs, try_malloc0)
376
/**
377
 * g_try_renew:
378
 * @struct_type: the type of the elements to allocate
379
 * @mem: the currently allocated memory
380
 * @n_structs: the number of elements to allocate
381
 * 
382
 * Attempts to reallocate the memory pointed to by @mem, so that it now has
383
 * space for @n_structs elements of type @struct_type, and returns %NULL on
384
 * failure. Contrast with g_renew(), which aborts the program on failure.
385
 * It returns the new address of the memory, which may have been moved.
386
 * The function returns %NULL if an overflow occurs.
387
 * 
388
 * Since: 2.8
389
 * Returns: a pointer to the new allocated memory, cast to a pointer to @struct_type
390
 */
391
#define g_try_renew(struct_type, mem, n_structs)  _G_RENEW (struct_type, mem, n_structs, try_realloc)
392
393
394
/* Memory allocation virtualization for debugging purposes
395
 * g_mem_set_vtable() has to be the very first GLib function called
396
 * if being used
397
 */
398
struct _GMemVTable {
399
  gpointer (*malloc)      (gsize    n_bytes);
400
  gpointer (*realloc)     (gpointer mem,
401
         gsize    n_bytes);
402
  void     (*free)        (gpointer mem);
403
  /* optional; set to NULL if not used ! */
404
  gpointer (*calloc)      (gsize    n_blocks,
405
         gsize    n_block_bytes);
406
  gpointer (*try_malloc)  (gsize    n_bytes);
407
  gpointer (*try_realloc) (gpointer mem,
408
         gsize    n_bytes);
409
};
410
GLIB_DEPRECATED_IN_2_46
411
void   g_mem_set_vtable (GMemVTable *vtable);
412
GLIB_DEPRECATED_IN_2_46
413
gboolean g_mem_is_system_malloc (void);
414
415
GLIB_VAR gboolean g_mem_gc_friendly;
416
417
/* Memory profiler and checker, has to be enabled via g_mem_set_vtable()
418
 */
419
GLIB_VAR GMemVTable *glib_mem_profiler_table;
420
GLIB_DEPRECATED_IN_2_46
421
void  g_mem_profile (void);
422
423
G_END_DECLS
424
425
#endif /* __G_MEM_H__ */