Zrythm
a highly automated and intuitive digital audio workstation
Toggle main menu visibility
Main Page
Related Pages
Topics
Data Structures
Data Structures
Data Structure Index
Class Hierarchy
Data Fields
All
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Functions
a
e
f
g
i
m
p
r
t
w
z
Variables
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Enumerations
Files
File List
Globals
All
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
z
Functions
_
a
b
c
d
e
f
g
h
i
l
m
n
o
p
q
r
s
t
u
v
w
z
Variables
Typedefs
Enumerations
a
b
c
e
f
g
i
k
m
n
p
r
s
t
u
z
Enumerator
a
u
z
Macros
_
a
b
c
d
e
f
h
i
k
m
p
r
s
t
u
v
z
▼
Zrythm
►
Documentation
►
Cyaml Schemas
GTK Tips
►
The Processing Cycle
repo-management
►
Release Checklist
►
Weblate Translations
Building on Windows
Building on Windows (MSVC)
CONTRIBUTING
HACKING
Git Packaging Hooks
Deprecated List
►
Topics
►
Data Structures
▼
Files
▼
File List
►
actions
►
doc
►
dsp
►
gui
►
io
►
plugins
►
project
►
settings
►
src
▼
utils
►
algorithms.h
arrays.h
►
audio.h
►
backtrace.h
►
cairo.h
chromaprint.h
►
color.h
►
compression.h
cpu_windows.h
►
curl.h
►
datetime.h
debug.h
dialogs.h
►
dictionary.h
dir.h
►
dsp.h
►
env.h
►
error.h
►
file.h
►
flags.h
►
general.h
►
gtk.h
hash.h
►
io.h
log.h
►
math.h
►
mem.h
►
midi.h
mpmc_queue.h
►
object_pool.h
objects.h
pango.h
pcg_rand.h
►
progress_info.h
►
resampler.h
►
resources.h
►
sort.h
►
stack.h
stoat.h
►
string.h
►
symap.h
►
system.h
terminal.h
►
types.h
►
ui.h
►
vamp.h
windows.h
windows_errors.h
yaml.h
dir.h
gtk_wrapper.h
project.h
libpanel_wrapper.h
Wrapper.h
►
zrythm.h
►
zrythm_app.h
INSTALL.rst
►
Globals
•
All
Data Structures
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
Modules
Pages
Loading...
Searching...
No Matches
objects.h
1
// SPDX-FileCopyrightText: © 2019-2023 Alexandros Theodotou <alex@zrythm.org>
2
// SPDX-License-Identifier: LicenseRef-ZrythmLicense
3
4
#ifndef __UTILS_OBJECTS_H__
5
#define __UTILS_OBJECTS_H__
6
7
#include <cstddef>
8
9
#include <gmodule.h>
10
17
NONNULL
static
inline
void
18
_object_zero_and_free (
void
** ptr,
size_t
sz)
19
{
20
if
(!*ptr)
21
return
;
22
23
memset (*ptr, 0, sz);
24
free (*ptr);
25
*ptr = NULL;
26
}
27
32
NONNULL
static
inline
void
33
_object_zero_and_free_unresizable (
void
** ptr,
size_t
sz)
34
{
35
if
(!*ptr)
36
return
;
37
38
memset (*ptr, 0, sz);
39
free (*ptr);
40
*ptr = NULL;
41
}
42
46
#define object_new(type) (type *) g_malloc0 (sizeof (type))
47
59
#define object_new_unresizable(type) object_new (type)
60
64
#define object_new_n_sizeof(n, sz) g_malloc0_n (n, sz)
65
69
#define object_new_n(n, type) \
70
(static_cast<type *> (object_new_n_sizeof (n, sizeof (type))))
69
#define object_new_n(n, type) \
…
71
72
#define object_realloc_n_sizeof(obj, prev_sz, sz) \
73
realloc_zero (obj, prev_sz, sz)
74
81
#define object_realloc_n(obj, prev_n, n, type) \
82
static_cast<type *> ( \
83
object_realloc_n_sizeof (obj, prev_n * sizeof (type), n * sizeof (type)))
81
#define object_realloc_n(obj, prev_n, n, type) \
…
84
90
#define object_set_to_zero(ptr) memset (ptr, 0, sizeof (*(ptr)))
91
97
#define object_free_unresizable(type, obj) free (obj)
98
103
#define object_zero_and_free(ptr) \
104
_object_zero_and_free ((void **) &(ptr), sizeof (*(ptr)))
103
#define object_zero_and_free(ptr) \
…
105
106
#define object_zero_and_free_unresizable(type, ptr) \
107
_object_zero_and_free_unresizable ((void **) &(ptr), sizeof (type))
108
113
#define object_free_w_func_and_null(_func, _obj) \
114
if (_obj) \
115
{ \
116
_func (_obj); \
117
_obj = NULL; \
118
}
113
#define object_free_w_func_and_null(_func, _obj) \
…
119
120
#define object_delete_and_null(_obj) \
121
if (_obj) \
122
{ \
123
delete _obj; \
124
_obj = nullptr; \
125
}
126
127
#define object_zero_and_free_if_nonnull(ptr) \
128
object_free_w_func_and_null (object_zero_and_free, ptr)
129
131
#define g_object_unref_and_null(ptr) \
132
object_free_w_func_and_null (g_object_unref, ptr)
131
#define g_object_unref_and_null(ptr) \
…
133
135
#define g_free_and_null(ptr) object_free_w_func_and_null (g_free, ptr)
136
138
#define g_error_free_and_null(ptr) \
139
object_free_w_func_and_null (g_error_free, ptr)
138
#define g_error_free_and_null(ptr) \
…
140
142
#define object_free_w_func_and_null_cast(_func, _cast, _obj) \
143
if (_obj) \
144
{ \
145
_func ((_cast) _obj); \
146
_obj = NULL; \
147
}
142
#define object_free_w_func_and_null_cast(_func, _cast, _obj) \
…
148
149
#define g_source_remove_and_zero(src_id) \
150
{ \
151
g_source_remove (src_id); \
152
src_id = 0; \
153
}
154
159
#endif
utils
objects.h
Generated by
1.11.0