libFirm
Loading...
Searching...
No Matches
Memory Allocation

Macros

#define XMALLOCN(type, n)
 Allocate n objects of a certain type.
 
#define XMALLOCNZ(type, n)
 Allocate n objects of a certain type and zero them.
 
#define XMALLOC(type)
 Allocate one object of a certain type.
 
#define XMALLOCZ(type)
 Allocate one object of a certain type and zero it.
 
#define XREALLOC(ptr, type, n)
 Reallocate n objects of a certain type.
 
#define XMALLOCF(type, member, n)
 Allocate an object with n elements of a flexible array member.
 
#define XMALLOCFZ(type, member, n)
 Allocate an object with n elements of a flexible array member and zero the whole object.
 
#define ALLOCAN(type, n)
 Allocate n objects of a certain type on the stack.
 
#define ALLOCANZ(type, n)
 Allocate n objects of a certain type on the stack and zero them.
 
#define ALLOCAF(type, member, n)
 Allocate an object with n elements of a flexible array member on the stack.
 
#define OALLOCN(obst, type, n)
 Allocate n objects of a certain type on the given obstack.
 
#define OALLOCNZ(obst, type, n)
 Allocate n objects of a certain type on the given obstack and zero them.
 
#define OALLOC(obst, type)
 Allocate one object of a certain type on the given obstack.
 
#define OALLOCZ(obst, type)
 Allocate one object of a certain type on the given obstack and zero it.
 
#define OALLOCF(obst, type, member, n)
 Allocate an object with n elements of a flexible array member on the given obstack.
 
#define OALLOCFZ(obst, type, member, n)
 Allocate an object with n elements of a flexible array member on the given obstack and zero the whole object.
 

Functions

void * xmalloc (size_t size)
 Allocate size bytes on the heap.
 
void * xrealloc (void *ptr, size_t size)
 Chane size of a previously allocated memory block to size bytes.
 
char * xstrdup (const char *str)
 Allocates memory and copies string str into it.
 

Detailed Description

Macro Definition Documentation

◆ ALLOCAF

#define ALLOCAF ( type,
member,
n )
Value:
((type*)alloca(offsetof(type, member) + sizeof(*((type*)0)->member) * (n)))

Allocate an object with n elements of a flexible array member on the stack.

Definition at line 107 of file xmalloc.h.

◆ ALLOCAN

#define ALLOCAN ( type,
n )
Value:
((type*)alloca(sizeof(type) * (n)))

Allocate n objects of a certain type on the stack.

Definition at line 97 of file xmalloc.h.

◆ ALLOCANZ

#define ALLOCANZ ( type,
n )
Value:
((type*)memset((type*)alloca(sizeof(type) * (n)), 0, sizeof(type) * (n)))

Allocate n objects of a certain type on the stack and zero them.

Definition at line 102 of file xmalloc.h.

◆ OALLOC

#define OALLOC ( obst,
type )
Value:
OALLOCN(obst, type, 1)
#define OALLOCN(obst, type, n)
Allocate n objects of a certain type on the given obstack.
Definition xmalloc.h:112

Allocate one object of a certain type on the given obstack.

Definition at line 122 of file xmalloc.h.

◆ OALLOCF

#define OALLOCF ( obst,
type,
member,
n )
Value:
((type*)obstack_alloc((obst), offsetof(type, member) + sizeof(*((type*)0)->member) * (n)))

Allocate an object with n elements of a flexible array member on the given obstack.

Definition at line 133 of file xmalloc.h.

◆ OALLOCFZ

#define OALLOCFZ ( obst,
type,
member,
n )
Value:
((type*)memset(OALLOCF((obst), type, member, (n)), 0, offsetof(type, member) + sizeof(*((type*)0)->member) * (n)))
#define OALLOCF(obst, type, member, n)
Allocate an object with n elements of a flexible array member on the given obstack.
Definition xmalloc.h:133

Allocate an object with n elements of a flexible array member on the given obstack and zero the whole object.

Definition at line 139 of file xmalloc.h.

◆ OALLOCN

#define OALLOCN ( obst,
type,
n )
Value:
((type*)obstack_alloc((obst), sizeof(type) * (n)))

Allocate n objects of a certain type on the given obstack.

Definition at line 112 of file xmalloc.h.

◆ OALLOCNZ

#define OALLOCNZ ( obst,
type,
n )
Value:
((type*)memset(OALLOCN((obst), type, (n)), 0, sizeof(type) * (n)))

Allocate n objects of a certain type on the given obstack and zero them.

Definition at line 117 of file xmalloc.h.

◆ OALLOCZ

#define OALLOCZ ( obst,
type )
Value:
OALLOCNZ(obst, type, 1)
#define OALLOCNZ(obst, type, n)
Allocate n objects of a certain type on the given obstack and zero them.
Definition xmalloc.h:117

Allocate one object of a certain type on the given obstack and zero it.

Definition at line 127 of file xmalloc.h.

◆ XMALLOC

#define XMALLOC ( type)
Value:
XMALLOCN(type, 1)
#define XMALLOCN(type, n)
Allocate n objects of a certain type.
Definition xmalloc.h:61

Allocate one object of a certain type.

Definition at line 71 of file xmalloc.h.

◆ XMALLOCF

#define XMALLOCF ( type,
member,
n )
Value:
((type*)xmalloc(offsetof(type, member) + sizeof(*((type*)0)->member) * (n)))
void * xmalloc(size_t size)
Allocate size bytes on the heap.

Allocate an object with n elements of a flexible array member.

Definition at line 86 of file xmalloc.h.

◆ XMALLOCFZ

#define XMALLOCFZ ( type,
member,
n )
Value:
((type*)memset(XMALLOCF(type, member, (n)), 0, offsetof(type, member) + sizeof(*((type*)0)->member) * (n)))
#define XMALLOCF(type, member, n)
Allocate an object with n elements of a flexible array member.
Definition xmalloc.h:86

Allocate an object with n elements of a flexible array member and zero the whole object.

Definition at line 92 of file xmalloc.h.

◆ XMALLOCN

#define XMALLOCN ( type,
n )
Value:
((type*)xmalloc(sizeof(type) * (n)))

Allocate n objects of a certain type.

Definition at line 61 of file xmalloc.h.

◆ XMALLOCNZ

#define XMALLOCNZ ( type,
n )
Value:
((type*)memset(xmalloc(sizeof(type) * (n)), 0, sizeof(type) * (n)))

Allocate n objects of a certain type and zero them.

Definition at line 66 of file xmalloc.h.

◆ XMALLOCZ

#define XMALLOCZ ( type)
Value:
XMALLOCNZ(type, 1)
#define XMALLOCNZ(type, n)
Allocate n objects of a certain type and zero them.
Definition xmalloc.h:66

Allocate one object of a certain type and zero it.

Definition at line 76 of file xmalloc.h.

◆ XREALLOC

#define XREALLOC ( ptr,
type,
n )
Value:
((type*)xrealloc(ptr, sizeof(type) * (n)))
void * xrealloc(void *ptr, size_t size)
Chane size of a previously allocated memory block to size bytes.

Reallocate n objects of a certain type.

Definition at line 81 of file xmalloc.h.

Function Documentation

◆ xmalloc()

void * xmalloc ( size_t size)

Allocate size bytes on the heap.

This is a wrapper for malloc which calls panic() in case of errors, so no error handling is required for code using it.

◆ xrealloc()

void * xrealloc ( void * ptr,
size_t size )

Chane size of a previously allocated memory block to size bytes.

This is a wrapper for realloc which calls panic() in case of errors, so no error handling is required for code using it.

◆ xstrdup()

char * xstrdup ( const char * str)

Allocates memory and copies string str into it.

This is a wrapper for strdup which calls panic() in case of errors, so no error handling is required for code using it.