Back to libut API Reference


    #include "libut/ut.h"
    char* UT_iob_flatten( UT_iob *iob, size_t *len );


This function copies the content of the iob into a new memory buffer (obtained using malloc(3)). The length of this buffer is placed in the location pointed to by len. The address of the buffer is returned. The caller must free(3) this buffer after using it.

Since a copy of the iob is made, any changes to the buffer do not affect the iob.


This function has the idiosyncracy of adding a trailing NULL to the buffer, but it is not counted in the length stored in len. This was construed as a feature at some point; the idea being that the guarantee of a NULL terminator made the flattened memory buffer amenable to being printed as a string.


UT_iob_create(3), UT_iob_printf(3), UT_iob_append(3), UT_iob_free(3), UT_iob_writefd(3), UT_iob_bufcmp(3), UT_iob_len(3)


Troy D. Hanson <>