Macros LIBISO_ALLOC_MEM, LIBISO_FREE_MEM for replaceing local variables

This commit is contained in:
Thomas Schmitt 2011-06-09 14:23:21 +02:00
parent 45d316d1ca
commit f08ae22dbe
2 changed files with 24 additions and 0 deletions

View File

@ -1887,3 +1887,13 @@ ex:;
} }
void *iso_alloc_mem(size_t size, size_t count, int flag)
{
void *pt;
pt = calloc(size, count);
if(pt == NULL)
iso_msg_submit(-1, ISO_OUT_OF_MEM, 0, "Out of virtual memory");
return pt;
}

View File

@ -539,4 +539,18 @@ int checksum_md5_xinfo_cloner(void *old_data, void **new_data, int flag);
/* ------------------------------------------------------------------------- */ /* ------------------------------------------------------------------------- */
void *iso_alloc_mem(size_t size, size_t count, int flag);
#define LIBISO_ALLOC_MEM(pt, typ, count) { \
pt= (typ *) iso_alloc_mem(sizeof(typ), (size_t) (count), 0); \
if(pt == NULL) { \
ret= -1; goto ex; \
} }
#define LIBISO_FREE_MEM(pt) { \
if(pt != NULL) \
free((char *) pt); \
}
#endif /*LIBISO_UTIL_H_*/ #endif /*LIBISO_UTIL_H_*/