1 /* grcboxprivate.h: Reference counted data
3 * Copyright 2018 Emmanuele Bassi
5 * SPDX-License-Identifier: LGPL-2.1-or-later
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, see <http://www.gnu.org/licenses/>.
34 #ifndef G_DISABLE_ASSERT
35 /* A "magic" number, used to perform additional integrity
36 * checks on the allocated data
43 gatomicrefcount ref_count;
48 #ifndef G_DISABLE_ASSERT
53 #define G_BOX_MAGIC 0x44ae2bf0
55 /* Keep the two refcounted boxes identical in size */
56 G_STATIC_ASSERT (sizeof (GRcBox) == sizeof (GArcBox));
58 /* This is the default alignment we use when allocating the
59 * refcounted memory blocks; it's similar to the alignment
60 * guaranteed by the malloc() in GNU's libc and by the GSlice
63 #define STRUCT_ALIGNMENT (2 * sizeof (gsize))
65 #define G_RC_BOX_SIZE sizeof (GRcBox)
66 #define G_ARC_BOX_SIZE sizeof (GArcBox)
68 gpointer g_rc_box_alloc_full (gsize block_size,