Code:
/** Il tipo che definisce un elemento */
typedef struct elem_t {
/** tipo dell'elemento */
int type;
/** il puntatore alla zona di memoria doce
l'elemento è allocato */
void *elm;
/** dimensione (in byte) dell'elemento */
unsigned int size;
}
elem_t;
elem_t* new_elem(int type, unsigned int size, void *e) {
elem_t *tmp;
ec_null( (tmp=(elem_t*)malloc(sizeof(elem_t))), NO_SET )
ec_null( (tmp->elm=malloc(size+1)), NO_SET )
ec_null( (tmp->elm=memcpy(tmp->elm, e, size+1)), NO_SET )
tmp->type=type;
tmp->size=size;
return tmp;
}
I would like to avoid the argument "size" int the function. thus to know the size of the memory referenced by "e".
Any suggestion??