Go to the source code of this file.
|
#define | HPD_CALLOC(PTR, NUM, CAST) |
| Allocates and zeros a structure. More...
|
|
#define | HPD_CPY_ALLOC(DST, SRC, CAST) |
|
#define | HPD_REALLOC(PTR, NUM, CAST) |
| CAST is for c++ compatibility (tests). More...
|
|
#define | HPD_SPRINTF_ALLOC(DST, FMT, ...) |
|
#define | HPD_STR_CPY(DST, SRC) |
|
#define | HPD_STR_N_CPY(DST, SRC, LEN) |
|
#define | HPD_VSPRINTF_ALLOC(DST, FMT, VP) |
|
#define HPD_CALLOC |
( |
|
PTR, |
|
|
|
NUM, |
|
|
|
CAST |
|
) |
| |
Value:do { \
(PTR) = (CAST *) calloc((NUM), sizeof(CAST)); \
if(!(PTR)) goto alloc_error; \
} while(0)
Allocates and zeros a structure.
CAST is for c++ compatibility (tests).
Definition at line 44 of file hpd_common.h.
#define HPD_CPY_ALLOC |
( |
|
DST, |
|
|
|
SRC, |
|
|
|
CAST |
|
) |
| |
Value:do { \
(DST) = (CAST *) malloc(sizeof(CAST)); \
if(!(DST)) goto alloc_error; \
memcpy((DST), (SRC), sizeof(CAST)); \
} while(0)
Definition at line 58 of file hpd_common.h.
#define HPD_REALLOC |
( |
|
PTR, |
|
|
|
NUM, |
|
|
|
CAST |
|
) |
| |
Value:do { \
void *_tmp = realloc((PTR), (NUM)*sizeof(CAST)); \
if(!_tmp) goto alloc_error; \
(PTR) = (CAST *) _tmp; \
} while(0)
CAST is for c++ compatibility (tests).
Definition at line 52 of file hpd_common.h.
#define HPD_SPRINTF_ALLOC |
( |
|
DST, |
|
|
|
FMT, |
|
|
|
... |
|
) |
| |
Value:do { \
size_t _len; \
if ((_len = snprintf(NULL, 0, (FMT), ##__VA_ARGS__)) < 0) goto snprintf_error; \
if (!((DST) = calloc(_len+1, sizeof(char)))) goto alloc_error; \
if (snprintf((DST), _len+1, (FMT), ##__VA_ARGS__) < 0) { free((DST)); goto snprintf_error; } \
} while (0)
Definition at line 75 of file hpd_common.h.
#define HPD_STR_CPY |
( |
|
DST, |
|
|
|
SRC |
|
) |
| |
Value:
strcpy((DST), (SRC)); \
} while(0)
#define HPD_REALLOC(PTR, NUM, CAST)
CAST is for c++ compatibility (tests).
Definition at line 64 of file hpd_common.h.
#define HPD_STR_N_CPY |
( |
|
DST, |
|
|
|
SRC, |
|
|
|
LEN |
|
) |
| |
Value:
strncpy((DST), (SRC), (LEN)); \
(DST)[LEN] = '\0'; \
} while(0)
#define HPD_REALLOC(PTR, NUM, CAST)
CAST is for c++ compatibility (tests).
Definition at line 69 of file hpd_common.h.
#define HPD_VSPRINTF_ALLOC |
( |
|
DST, |
|
|
|
FMT, |
|
|
|
VP |
|
) |
| |
Value:do { \
size_t _len; \
va_list _vp; \
va_copy(_vp, (VP)); \
if ((_len = vsnprintf(NULL, 0, (FMT), _vp)) < 0) { \
va_end(_vp); \
goto vsnprintf_error; \
} \
va_end(_vp); \
if (!((DST) = calloc(_len+1, sizeof(char)))) goto alloc_error; \
if (vsnprintf((DST), _len+1, (FMT), (VP)) < 0) {
free((DST));
goto vsnprintf_error; } \
} while (0)
Definition at line 82 of file hpd_common.h.