Beast - Music Synthesizer and Composer  0.11.1+10.g2da35
sfimemory.hh
Go to the documentation of this file.
1  // Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
2 #ifndef __SFI_MEMORY_H__
3 #define __SFI_MEMORY_H__
4 
5 #include <sfi/sfitypes.hh>
6 
7 
8 /* --- macros --- */
9 #define sfi_new_struct(type, n) ((type*) sfi_alloc_memblock (sizeof (type) * (n)))
10 #define sfi_new_struct0(type, n) ((type*) sfi_alloc_memblock0 (sizeof (type) * (n)))
11 #define sfi_delete_struct(type, mem) (sfi_delete_structs (type, 1, (mem)))
12 #ifndef __GNUC__
13 # define sfi_delete_structs(type, n, mem) (sfi_free_memblock (sizeof (type) * (n), (mem)))
14 #else /* provide typesafety if possible */
15 # define sfi_delete_structs(type, n, mem) ({ \
16  type *__typed_pointer = (mem); \
17  sfi_free_memblock (sizeof (type) * (n), __typed_pointer); \
18 })
19 #endif
20 #define SFI_ALIGNED_SIZE(size,align) ((align) > 0 ? _SFI_INTERN_ALIGN (((gsize) (size)), ((gsize) (align))) : (gsize) (size))
21 #define _SFI_INTERN_ALIGN(s, a) (((s + (a - 1)) / a) * a)
22 #define SFI_STD_ALIGN (MAX (MAX (sizeof (float), sizeof (int)), sizeof (void*)))
23 
24 
25 /* --- implementation --- */
26 gpointer sfi_alloc_memblock (gsize size);
27 gpointer sfi_alloc_memblock0 (gsize size);
28 void sfi_free_memblock (gsize size,
29  gpointer memblock);
30 void sfi_alloc_report (void);
31 gulong sfi_alloc_upper_power2 (const gulong number);
32 void _sfi_free_node_list (gpointer mem,
33  gsize node_size);
34 #endif /* __SFI_MEMORY_H__ */
35 /* vim:set ts=8 sts=2 sw=2: */