Merge branch 'test-ip_mreq_source-android-only' into 'master'
[glib.git] / glib / grcboxprivate.h
blob8b0d8dd4e19ebad9c07282eb559dbe15869b0449
1 /* grcboxprivate.h: Reference counted data
3 * Copyright 2018 Emmanuele Bassi
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, see <http://www.gnu.org/licenses/>.
19 #pragma once
21 #include "gtypes.h"
22 #include "grcbox.h"
24 G_BEGIN_DECLS
26 typedef struct {
27 grefcount ref_count;
29 gsize mem_size;
31 #ifndef G_DISABLE_ASSERT
32 /* A "magic" number, used to perform additional integrity
33 * checks on the allocated data
35 guint32 magic;
36 #endif
37 } GRcBox;
39 typedef struct {
40 gatomicrefcount ref_count;
42 gsize mem_size;
44 #ifndef G_DISABLE_ASSERT
45 guint32 magic;
46 #endif
47 } GArcBox;
49 #define G_BOX_MAGIC 0x44ae2bf0
51 /* Keep the two refcounted boxes identical in size */
52 G_STATIC_ASSERT (sizeof (GRcBox) == sizeof (GArcBox));
54 #define G_RC_BOX_SIZE sizeof (GRcBox)
55 #define G_ARC_BOX_SIZE sizeof (GArcBox)
57 gpointer g_rc_box_alloc_full (gsize block_size,
58 gboolean atomic,
59 gboolean clear);
61 G_END_DECLS