journaldapihelper.c
struct iovec * _new_iovec ( AV * av, int * i)
    {
    SSize_t siz = av_len(av) + 1 ;
    struct iovec * ret = NULL;

    *i = siz ;
    ret = malloc( siz*sizeof(struct iovec)) ;

    if ( ! ret )
        croak("out of memory") ;

    struct iovec * cursor = ret ;

    for ( SSize_t j=0; j<siz; j++  )
        {
        SV** svp = av_fetch(av, j,1) ;
        if ( svp )
            {
            STRLEN key_len ;
            char * key = SvPVbyte(*svp, key_len) ;
            cursor->iov_base = (void *) key ;
            cursor->iov_len  = (size_t) key_len ;
            cursor++ ;
            }
        }
    return ret ;
    }
// create an iovec from an array. the iovec wil point into
// the array entries which will be invalid as the array changes
// But thats ok because we just log this out and then free the
// iovec again.
create an iovec from an array. the iovec wil point into
the array entries which will be invalid as the array changes
But thats ok because we just log this out and then free the
iovec again.
create an iovec from an array . the iovec wil point into the array entries which will be invalid as the array changes But thats ok because we just log this out and then free the iovec again .
struct iovec * _new_iovec ( AV * av, int * i)
    {
    SSize_t siz = av_len(av) + 1 ;
    struct iovec * ret = NULL;
    *i = siz ;
    ret = malloc( siz*sizeof(struct iovec)) ;
    if ( ! ret )
        croak("out of memory") ;
    struct iovec * cursor = ret ;
    for ( SSize_t j=0; j<siz; j++  )
        {
        SV** svp = av_fetch(av, j,1) ;
        if ( svp )
            {
            STRLEN key_len ;
            char * key = SvPVbyte(*svp, key_len) ;
            cursor->iov_base = (void *) key ;
            cursor->iov_len  = (size_t) key_len ;
            cursor++ ;
            }
        }
    return ret ;
    }
struct iovec * _new_iovec ( AV * av , int * i ) { SSize_t siz = av_len ( av ) + 1 ; struct iovec * ret = NULL ; * i = siz ; ret = malloc ( siz * sizeof ( struct iovec ) ) ; if ( ! ret ) croak ( " " ) ; struct iovec * cursor = ret ; for ( SSize_t j = 0 ; j < siz ; j ++ ) { SV * * svp = av_fetch ( av , j , 1 ) ; if ( svp ) { STRLEN key_len ; char * key = SvPVbyte ( * svp , key_len ) ; cursor -> iov_base = ( void * ) key ; cursor -> iov_len = ( size_t ) key_len ; cursor ++ ; } } return ret ; }
create an iovec from an array.
create an iovec from an array .