Go to the documentation of this file.
27 #ifndef FIRM_ADT_XMALLOC_H
28 #define FIRM_ADT_XMALLOC_H
38 #if defined(__linux__) || defined(__APPLE__)
72 #define xfree(ptr) free(ptr)
77 #define XMALLOCN(type, n) ((type*)xmalloc(sizeof(type) * (n)))
82 #define XMALLOCNZ(type, n) ((type*)memset(xmalloc(sizeof(type) * (n)), 0, sizeof(type) * (n)))
87 #define XMALLOC(type) XMALLOCN(type, 1)
92 #define XMALLOCZ(type) XMALLOCNZ(type, 1)
97 #define XREALLOC(ptr, type, n) ((type*)xrealloc(ptr, sizeof(type) * (n)))
102 #define XMALLOCF(type, member, n) ((type*)xmalloc(offsetof(type, member) + sizeof(*((type*)0)->member) * (n)))
108 #define XMALLOCFZ(type, member, n) ((type*)memset(XMALLOCF(type, member, (n)), 0, offsetof(type, member) + sizeof(*((type*)0)->member) * (n)))
113 #define ALLOCAN(type, n) ((type*)alloca(sizeof(type) * (n)))
118 #define ALLOCANZ(type, n) ((type*)memset((type*)alloca(sizeof(type) * (n)), 0, sizeof(type) * (n)))
123 #define OALLOCN(obst, type, n) ((type*)obstack_alloc((obst), sizeof(type) * (n)))
128 #define OALLOCNZ(obst, type, n) ((type*)memset(OALLOCN((obst), type, (n)), 0, sizeof(type) * (n)))
133 #define OALLOC(obst, type) OALLOCN(obst, type, 1)
138 #define OALLOCZ(obst, type) OALLOCNZ(obst, type, 1)
144 #define OALLOCF(obst, type, member, n) ((type*)obstack_alloc((obst), offsetof(type, member) + sizeof(*((type*)0)->member) * (n)))
150 #define OALLOCFZ(obst, type, member, n) ((type*)memset(OALLOCF((obst), type, member, (n)), 0, offsetof(type, member) + sizeof(*((type*)0)->member) * (n)))