src/fmt.c
/** \brief Reset/close destination string.
 * 
 * Ensures, string is zero terminated (if cap allows that).
 * Then it sets *dst to NULL so any further errorneous writes segfault.
 * And sets *cap to 0 so no writes should be attempted anyway.
 *
 * (NULL,NULL) - NOP
 * (_, ->?) - *cap = 0
 * (->?, ->1+) - *dst = NULL
 */
\brief Reset/close destination string.

Ensures, string is zero terminated (if cap allows that).
Then it sets *dst to NULL so any further errorneous writes segfault.
And sets *cap to 0 so no writes should be attempted anyway.


\ brief Reset / close destination string . Ensures string is zero terminated ( if cap allows that ) . Then it sets * dst to NULL so any further errorneous writes segfault . And sets * cap to 0 so no writes should be attempted anyway .
void str_rst_dst(char ** dst, size_t * cap)
{
    size_t old_cap = 0;
    if(cap)
    {
        old_cap = *cap;
        *cap = 0; 
    }
    if(dst && *dst)
    {
        if(old_cap > 0)
        {
            **dst = '\0';
        }
        *dst = NULL;
    }
}
void str_rst_dst ( char * * dst , size_t * cap ) { size_t old_cap = 0 ; if ( cap ) { old_cap = * cap ; * cap = 0 ; } if ( dst && * dst ) { if ( old_cap > 0 ) { * * dst = ' \0 ' ; } * dst = NULL ; } }
\brief Reset/close destination string.
\ brief Reset / close destination string .
// force remaining capacity to 0 // zero terminate if possible // force dst to NULL