Allocating memory for an LO-specification structure

When you pass a NULL-valued pointer as the second argument of the mi_lo_spec_init() function, this function allocates an LO-specification structure.

Server only: This new LO-specification structure has the current memory duration.
The following code fragment declares a pointer named myspec and initializes this pointer to NULL:
MI_LO_SPEC *myspec;
MI_CONNECTION *conn;
...
/* Allocate a new LO-specification structure */
myspec = NULL;
if ( mi_lo_spec_init(conn, &myspec) != MI_OK )
   handle_error();
/* Perform tasks with LO-specification structure */
...

/* Once finished with LO-specification structure, free it */
if ( mi_lo_spec_free(conn, myspec)!= MI_OK )
   handle_error();

After the execution of mi_lo_spec_init(), the myspec variable points to the newly allocated LO-specification structure.

If you provide a second argument that does not point to NULL, the mi_lo_spec_init() function assumes that this pointer references an existing LO-specification structure that a previous call to mi_lo_spec_init() has allocated. An LO-specification pointer that is not NULL allows a DataBlade® API module to reuse an LO-specification structure. The following code fragment reuses the LO-specification structure that the LO_spec pointer references when the first_time flag is false:
MI_CONNECTION *conn;
MI_LO_SPEC *LO_spec = NULL;
mi_integer first_time = 1;
...
if ( first_time )
   {
   ...
   LO_spec = NULL; /* tell interface to allocate memory */
   first_time = 0; /* set "first_time" flag to false */
   ...
   }
if ( mi_lo_spec_init(conn, &LO_spec) != MI_OK )
   {
   /* error */
   }
Important: Before you use an LO-specification structure, make sure that you either call mi_lo_spec_init() with the LO-specification pointer set to NULL, or that you have initialized this pointer with a previous call to mi_lo_spec_init().

After you have a valid LO-specification structure, you can use the accessor functions to obtain the storage characteristics from this LO-specification structure.

For the syntax of mi_lo_spec_init(), see the Informix® DataBlade API Function Reference.