byte *cf_op_names[] = { CF_OPERATIONS };
#undef T
+#define DARY_HDR_SIZE ALIGN(sizeof(uns), CPU_STRUCT_ALIGN)
+
static byte *
interpret_set_dynamic(struct cf_item *item, int number, byte **pars, void **ptr)
{
cf_journal_block(ptr, sizeof(void*));
// boundary checks done by the caller
uns size = cf_type_size(item->type, item->u.utype);
- ASSERT(size >= sizeof(uns));
- *ptr = cf_malloc(sizeof(uns) + number * size) + sizeof(uns);
+ *ptr = cf_malloc(DARY_HDR_SIZE + number * size) + DARY_HDR_SIZE;
DARY_LEN(*ptr) = number;
return cf_parse_ary(number, pars, *ptr, type, &item->u);
}
int taken = MIN(number, ABS(item->number)-old_nr);
*processed = taken;
// stretch the dynamic array
- void *new_p = cf_malloc(sizeof(uns) + (old_nr + taken) * size) + sizeof(uns);
+ void *new_p = cf_malloc(DARY_HDR_SIZE + (old_nr + taken) * size) + DARY_HDR_SIZE;
DARY_LEN(new_p) = old_nr + taken;
cf_journal_block(ptr, sizeof(void*));
*ptr = new_p;
#define CF_USER(n,p,t) { .cls = CC_STATIC, .type = CT_USER, .name = n, .number = 1, .ptr = p, .u.utype = t }
#define CF_USER_ARY(n,p,t,c) { .cls = CC_STATIC, .type = CT_USER, .name = n, .number = c, .ptr = p, .u.utype = t }
#define CF_USER_DYN(n,p,t,c) { .cls = CC_DYNAMIC, .type = CT_USER, .name = n, .number = c, .ptr = p, .u.utype = t }
- // Beware that CF_USER_DYN can only be used on user-defined types of size at least 4
/* If you aren't picky about the number of parameters */
#define CF_ANY_NUM -0x7fffffff