mco_uda_field_alloc

Allocate vector elements.

Prototype

    MCO_RET mco_uda_field_alloc(	/*IN*/ const mco_uda_object_handle_p obj,
                    /*IN*/ unsigned short field_no,
                    /*IN*/ unsigned short length );

Arguments

obj
The object handle.
field_no
The field number (must be between 0 and struct_info.field_count - 1).
length
The number of elements to allocate.

Description

Allocate a vector field.

Return Codes

MCO_S_OK
Vector field successfully allocated.
MCO_E_UDA_FIELD_NOT_FOUND
Invalid field_no - field not found in this class or struct.
MCO_E_UDA_NOT_DYNAMIC
The field referenced by field_no is not a vector.

Example

    Application snippet:

    int main(int argc, char* argv[])
    {
        MCO_RET rc;
        mco_uda_object_handle_t obj;
     mco_uda_value_t val;
     unsigned short field_no = 1;
     unsigned short vlength = 3;
     unsigned short j;
     char buf[1024];

        ...

        /* Put a vector of chars */
        mco_uda_field_alloc(&obj, field_no, vlength); /* Allocate vector */

        val.type = MCO_DD_CHAR;  /* Set field's type */
        val.v.p.p.c = buf;       /* Set pointer to buffer */
        val.v.p.len = 20;        /* Set string length */
        for (j = 0; j < vlength; ++j)
        {
            sprintf(buf, "vch-%d:%d", 1, j); /* Put value to buffer */
         mco_uda_put(&obj, field_no, j, &val); /* Put value to object */
        }
        ...
    }

Files

Header file:
mcouda.h
Source file:
mcouda.c
Library:
libmcouda.a