Obtain the data length

The mi_get_varlen() function returns the data length from a varying-length descriptor.

Keep in mind the following restrictions about data length:
  • Do not assume that the data in a varying-length structure is null-terminated.

    Always use the data length to determine the end of the varying-length data when you perform operations on this data.

  • When you increase the length of the data with mi_set_varlen(), this function does not automatically increase the amount of memory allocated to the data portion.

    You must ensure that there is sufficient space in the data portion to hold the varying-length data. If there is insufficient space, allocate a new data portion with a DataBlade® API memory-management function (such as mi_dalloc()) and assign a pointer to this new memory to the data pointer of your varying-length structure.

For the varying-length structure in Memory allocated for a varying-length structure, a call to mi_get_varlen() returns 200. For the varying-length structure that Format of a varying-length structure shows, a call to mi_get_varlen() returns 110.