1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
/*
* Copyright © 2012 Intel Corporation
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*
* Author: Benjamin Segovia <benjamin.segovia@intel.com>
*/
#ifndef __CL_ALLOC_H__
#define __CL_ALLOC_H__
#include <stdlib.h>
/* Return a valid pointer for the requested memory block size */
extern void* cl_malloc(size_t sz, char* file, int line);
#define CL_MALLOC(SZ) cl_malloc(SZ, __FILE__, __LINE__)
/* Aligned malloc */
extern void* cl_aligned_malloc(size_t sz, size_t align, char* file, int line);
#define CL_ALIGNED_MALLOC(SZ, ALIGN) cl_aligned_malloc(SZ, ALIGN, __FILE__, __LINE__)
/* malloc + memzero */
extern void* cl_calloc(size_t n, size_t elem_size, char* file, int line);
#define CL_CALLOC(N, ELEM_SIZE) cl_calloc(N, ELEM_SIZE, __FILE__, __LINE__)
/* Regular realloc */
extern void* cl_realloc(void *ptr, size_t sz, char* file, int line);
#define CL_REALLOC(PTR, SZ) cl_realloc(PTR, SZ, __FILE__, __LINE__)
/* Free a pointer allocated with cl_*alloc */
extern void cl_free(void *ptr, char* file, int line);
#define CL_FREE(PTR) cl_free(PTR, __FILE__, __LINE__)
/* We count the number of allocation. This function report the number of
* allocation still unfreed
*/
extern void cl_alloc_report_unfreed(void);
extern void cl_alloc_debug_init(void);
#endif /* __CL_ALLOC_H__ */
|