Create a varying-length structure
Accessor function name | Description |
---|---|
mi_new_var() | Creates a new varying-length structure with a data portion of the specified size |
mi_streamread_lvarchar() | Reads a varying-length structure (mi_lvarchar) value from a stream and copies the value to a buffer |
mi_string_to_lvarchar() | Creates a new varying-length structure and puts
the specified null-terminated string into the data portion
The data does not contain a null terminator once it is copied to the data portion. |
mi_var_copy() | Allocates and creates a copy of an existing varying-length
structure
The copy contains its own data portion with the same varying-length data as the original varying-length structure. |
- The varying-length descriptor is a fixed-length structure that
stores the metadata for the varying-length data.
The allocation functions allocate the varying-length descriptor and set the data length and the data pointer in this descriptor.
- The data portion contains the actual varying-length data.
The allocation functions allocate the data portion with the length that is specified in the varying-length descriptor. They then set the data pointer in the varying-length descriptor to point to this data portion.
mi_lvarchar *new_lvarch;
...
new_lvarch = mi_new_var(200);
The allocation functions in Table 1 return the newly allocated varying-length structure as a pointer to an mi_lvarchar data type. For example, the call to mi_new_var() in Figure 1 allocates a new mi_lvarchar structure with a data portion of 200 bytes.
mi_sendrecv *new_sndrcv;
...
new_sndrcv = (mi_sendrecv *)mi_new_var(30);
This cast is not strictly required, but many compilers recommend it and it does improve clarity of purpose.