libvisual  0.5.0
lv_mem.h
1 /* Libvisual - The audio visualisation framework.
2  *
3  * Copyright (C) 2012 Libvisual team
4  * 2004-2006 Dennis Smit
5  *
6  * Authors: Dennis Smit <ds@nerds-incorporated.org>
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU Lesser General Public License as
10  * published by the Free Software Foundation; either version 2.1
11  * of the License, or (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21  */
22 
23 #ifndef _LV_MEM_H
24 #define _LV_MEM_H
25 
26 #include <libvisual/lvconfig.h>
27 #include <libvisual/lv_defines.h>
28 
43 typedef void *(*VisMemCopyFunc)(void *dest, const void *src, visual_size_t n);
44 
57 typedef void *(*VisMemCopyPitchFunc)(void *dest, const void *src, int pitch1, int pitch2, int width, int rows);
58 
68 typedef void *(*VisMemSet8Func)(void *dest, int c, visual_size_t n);
69 
79 typedef void *(*VisMemSet16Func)(void *dest, int c, visual_size_t n);
80 
90 typedef void *(*VisMemSet32Func)(void *dest, int c, visual_size_t n);
91 
92 LV_BEGIN_DECLS
93 
101 LV_API void *visual_mem_malloc (visual_size_t size) LV_ATTR_MALLOC;
102 
111 LV_API void *visual_mem_malloc0 (visual_size_t size) LV_ATTR_MALLOC;
112 
121 LV_API void *visual_mem_realloc (void *ptr, visual_size_t size) LV_ATTR_MALLOC;
122 
130 LV_API void visual_mem_free (void *ptr);
131 
142 LV_API void *visual_mem_malloc_aligned (visual_size_t size, visual_size_t alignment);
143 
151 LV_API void visual_mem_free_aligned (void *ptr);
152 
153 /* Optimal performance functions set by visual_mem_initialize(). */
154 extern LV_API VisMemCopyFunc visual_mem_copy;
155 extern LV_API VisMemCopyPitchFunc visual_mem_copy_pitch;
156 
157 extern LV_API VisMemSet8Func visual_mem_set;
158 extern LV_API VisMemSet16Func visual_mem_set16;
159 extern LV_API VisMemSet32Func visual_mem_set32;
160 
169 #define visual_mem_new0(struct_type, n_structs) \
170  ((struct_type *) visual_mem_malloc0 (((visual_size_t) sizeof (struct_type)) * ((visual_size_t) (n_structs))))
171 
172 LV_END_DECLS
173 
178 #endif /* _LV_MEM_H */