P99
Macros | Functions
p99_new.h File Reference

Macros for initialization and allocation. More...

#include "p99_c99.h"
#include "p99_int.h"
+ Include dependency graph for p99_new.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define P99_ALLOC(...)   P99_IF_GT(P99_NARG(__VA_ARGS__), 1)(P00_ALLOC(__VA_ARGS__))(P00_VMALLOC(__VA_ARGS__))
 
#define P99_APLAIN(...)
 
#define P99_ASUB(X, T, N, L)
 
#define P99_CALLOC(T, N)
 A type oriented replacement for calloc. More...
 
#define P99_DECLARE_DELETE(T)
 Declare a ‘delete’ operator for type T. More...
 
#define P99_DEFINE_DELETE(T)   P99_INSTANTIATE(void, P99_PASTE2(T, _delete), T const*)
 
#define P99_FCALLOC(T, F, N)   calloc(P99_FSIZEOF(T, F, N),1)
 Allocate an instance of struct T that is able to hold N items in flexible struct member F. More...
 
#define P99_FHEAD(T, F, P)   ((T*)(((char*)P) - offsetof(T, F)))
 For a pointer P to a flexible struct member F in struct T find the start address of the container. More...
 
#define P99_FMALLOC(T, F, N)   malloc(P99_FSIZEOF(T, F, N))
 Allocate an instance of struct T that is able to hold N items in flexible struct member F. More...
 
#define P99_FREALLOC(P, T, F, N)   realloc(P, P99_FSIZEOF(T, F, N))
 Reallocate an instance P of struct T such that it is able to hold N items in flexible struct member F. More...
 
#define P99_FSIZEOF(T, F, N)   P99_MAXOF(sizeof(T), offsetof(T, F) + P99_SIZEOF(T, F[0]) * N)
 Compute the size for an instance of struct T that is able to hold N items in flexible struct member F. More...
 
#define P99_INITIALIZE(X, L)   P00_ABLESS(P00_INITIALIZE((X), (L)), *(X))
 
#define P99_MALLOC(X)   malloc(sizeof(X))
 A type oriented malloc wrapper. More...
 
#define P99_MAXOF(A, B)   ((A) < (B) ? (B) : (A))
 
#define P99_MEMSET(TA, SO, N)   p00_memset((TA), (void const*)&(SO), sizeof(SO), N)
 A type oriented replacement for memset. More...
 
#define P99_MEMZERO(T, TA, N)   p00_memset((TA), (void const*)&P99_LVAL(const T), sizeof(T), N)
 A type oriented replacement for memset with argument 0. More...
 
#define P99_MINOF(A, B)   ((A) < (B) ? (A) : (B))
 
#define P99_NEW(...)   P99_IF_LT(P99_NARG(__VA_ARGS__), 2)(P00_NEW(__VA_ARGS__))(P00_NEW_ARGS(__VA_ARGS__))
 Allocate an element of type T as given by the first argument and initialize it with the remaining arguments, if any. More...
 
#define P99_PZERO(X, N)   (memset((X), 0, sizeof(X[0]) * N))
 Zero out all bits in the object to which X points. More...
 
#define P99_REALLOC(X, T)   realloc((X), sizeof(T))
 A type oriented realloc wrapper. More...
 
#define P99_SIZEOF(T, F, ...)   P99_IF_EQ(P99_NARG(__VA_ARGS__), 1)(sizeof(__VA_ARGS__))(P00_SIZEOF2(__VA_ARGS__))
 Determine the size of field F in structure T. More...
 
#define P99_TZERO(X)   (memset(&(X), 0, sizeof(X)))
 Zero out all bits in the object X. More...
 

Functions

size_t p99_maxof (size_t p00_m, size_t p00_n)
 

Detailed Description

Macros for initialization and allocation.

See also
Initialization facilities through the preprocessor

Definition in file p99_new.h.

p
P00_CLAUSE2 p(P00_WEAK1(p00_cb))(P00_WEAK2(p00_cb)) pp99_callback_stack p00_at_quick_exit
P99_PASTE2
#define P99_PASTE2(_1, _2)
Paste two token sequences at their junction.
Definition: p99_paste.h:82
P99_CALLOC
#define P99_CALLOC(T, N)
A type oriented replacement for calloc.
Definition: p99_new.h:268
P99_NARG
#define P99_NARG(...)
Return the length of the variable length argument list, where an empty argument list is considered to...
Definition: p99_args.h:117
P99_REALLOC
#define P99_REALLOC(X, T)
A type oriented realloc wrapper.
Definition: p99_new.h:228
P99_LVAL
#define P99_LVAL(...)
Define an lvalue of type T, where T is the first parameter in the variable parameter list.
Definition: p99_int.h:1084
P99_MALLOC
#define P99_MALLOC(X)
A type oriented malloc wrapper.
Definition: p99_new.h:190