/*--------------------------------------------------------------------------- | Facility : libnform | Function : TypeArgument *_nc_Copy_Argument(const FIELDTYPE *typ, | const TypeArgument *argp, | int *err ) | | Description : Create a copy of an argument structure for the specified | type. | | Return Values : Pointer to argument structure. Maybe NULL. | In case of an error in *err an errorcounter is increased. +--------------------------------------------------------------------------*/ TypeArgument* _nc_Copy_Argument(const FIELDTYPE *typ, const TypeArgument *argp, int *err) { TypeArgument *res = (TypeArgument *)0; TypeArgument *p; if ( typ && (typ->status & _HAS_ARGS) ) { assert(err && argp); if (typ->status & _LINKED_TYPE) { p = (TypeArgument *)malloc(sizeof(TypeArgument)); if (p) { p->left = _nc_Copy_Argument(typ,argp->left ,err); p->right = _nc_Copy_Argument(typ,argp->right,err); return p; } *err += 1; } else { if (typ->copyarg) { if (!(res = (TypeArgument *)(typ->copyarg((const void *)argp)))) *err += 1; } else res = (TypeArgument *)argp; } } return res; }
_nc_Copy_Type(FIELD *dst, FIELD const *src) { int err = 0; assert(dst != 0 && src != 0); dst->type = src->type; dst->arg = (void *)_nc_Copy_Argument(src->type, (TypeArgument *)(src->arg), &err); if (err != 0) { _nc_Free_Argument(dst->type, (TypeArgument *)(dst->arg)); dst->type = (FIELDTYPE *)0; dst->arg = (void *)0; return FALSE; } else { if (dst->type != 0) { dst->type->ref++; } return TRUE; } }