Hitmap 1.3
 All Data Structures Namespaces Files Functions Variables Typedefs Friends Macros Groups Pages
hit_allocP.h
Go to the documentation of this file.
1 
21 /*
22  * <license>
23  *
24  * Hitmap v1.2
25  *
26  * This software is provided to enhance knowledge and encourage progress in the scientific
27  * community. It should be used only for research and educational purposes. Any reproduction
28  * or use for commercial purpose, public redistribution, in source or binary forms, with or
29  * without modifications, is NOT ALLOWED without the previous authorization of the copyright
30  * holder. The origin of this software must not be misrepresented; you must not claim that you
31  * wrote the original software. If you use this software for any purpose (e.g. publication),
32  * a reference to the software package and the authors must be included.
33  *
34  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS "AS IS" AND ANY
35  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
36  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
37  * THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
38  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
39  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
40  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
41  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
42  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
43  *
44  * Copyright (c) 2007-2015, Trasgo Group, Universidad de Valladolid.
45  * All rights reserved.
46  *
47  * More information on http://trasgo.infor.uva.es/
48  *
49  * </license>
50 */
51 
52 #ifndef _HitAllocP_
53 #define _HitAllocP_
54 
55 
56 #include <stdlib.h>
57 #include "hit_error.h"
58 
59 
72 #define hit_vmalloc(ptr, size) \
73 { \
74  ptr = (void *)malloc((size_t)(size)); \
75  if(ptr == NULL) hit_errInternal(__func__,"Memory allocation request failed","",__FILE__,__LINE__) \
76 }
77 
93 #define hit_malloc(ptr, type, nmemb) \
94 { \
95  ptr = (type *)malloc(sizeof(type)* (size_t)(nmemb)); \
96  if(ptr == NULL) hit_errInternal(__func__,"Memory allocation request failed","",__FILE__,__LINE__) \
97 }
98 
99 
114 #define hit_calloc(ptr, type, nmemb) \
115 { \
116  ptr = (type *)calloc( (size_t)(nmemb), sizeof(type)); \
117  if(ptr == NULL) hit_errInternal(__func__,"Memory allocation request failed","",__FILE__,__LINE__) \
118 }
119 
134 #define hit_realloc(ptr, type, nmemb) \
135 { \
136  ptr = (type *)realloc(ptr, sizeof(type)* (size_t)(nmemb)); \
137  if(ptr == NULL) hit_errInternal(__func__,"Memory rellocation request failed","",__FILE__,__LINE__) \
138 }
139 
140 
152 #define hit_free(ptr) \
153 { \
154  free(ptr); \
155  ptr = NULL; \
156 }
157 
158 
159 
160 /* END OF HEADER FILE _HitAllocP_ */
161 #endif