openbmc/build/tmp/deploy/sdk/witherspoon-2019-08-08/sysroots/armv6-openbmc-linux-gnueabi/usr/src/debug/rsyslog/8.1903.0-r0/rsyslog-8.1903.0/runtime/msg.c
void MsgSetHOSTNAME(smsg_t * pThis, const uchar* pszHOSTNAME,
                        const int lenHOSTNAME)
    {
        assert(pThis != NULL);

        freeHOSTNAME(pThis);

        pThis->iLenHOSTNAME = lenHOSTNAME;
        if (pThis->iLenHOSTNAME < CONF_HOSTNAME_BUFSIZE)
        {
            /* small enough: use fixed buffer (faster!) */
            pThis->pszHOSTNAME = pThis->szHOSTNAME;
        }
        else if ((pThis->pszHOSTNAME =
                      (uchar*)malloc(pThis->iLenHOSTNAME + 1)) == NULL)
        {
            /* truncate message, better than completely loosing it... */
            pThis->pszHOSTNAME = pThis->szHOSTNAME;
            pThis->iLenHOSTNAME = CONF_HOSTNAME_BUFSIZE - 1;
        }

        memcpy(pThis->pszHOSTNAME, pszHOSTNAME, pThis->iLenHOSTNAME);
        pThis->pszHOSTNAME[pThis->iLenHOSTNAME] =
            '\0'; /* this also works with truncation! */
    }
/* rgerhards 2004-11-09: set HOSTNAME in msg object
     * rgerhards, 2007-06-21:
     * Does not return anything. If an error occurs, the hostname is
     * simply not set. I have changed this behaviour. The only problem
     * we can run into is memory shortage. If we have such, it is better
     * to loose the hostname than the full message. So we silently ignore
     * that problem and hope that memory will be available the next time
     * we need it. The rest of the code already knows how to handle an
     * unset HOSTNAME.
     */
rgerhards 2004-11-09: set HOSTNAME in msg object
rgerhards, 2007-06-21:
Does not return anything. If an error occurs, the hostname is
simply not set. I have changed this behaviour. The only problem
we can run into is memory shortage. If we have such, it is better
to loose the hostname than the full message. So we silently ignore
that problem and hope that memory will be available the next time
we need it. The rest of the code already knows how to handle an
unset HOSTNAME.
rgerhards 2004 - 11 - 09 : set HOSTNAME in msg object rgerhards 2007 - 06 - 21 : Does not return anything . If an error occurs the hostname is simply not set . I have changed this behaviour . The only problem we can run into is memory shortage . If we have such it is better to loose the hostname than the full message . So we silently ignore that problem and hope that memory will be available the next time we need it . The rest of the code already knows how to handle an unset HOSTNAME .
void MsgSetHOSTNAME(smsg_t * pThis, const uchar* pszHOSTNAME,
                        const int lenHOSTNAME)
    {
        assert(pThis != NULL);
        freeHOSTNAME(pThis);
        pThis->iLenHOSTNAME = lenHOSTNAME;
        if (pThis->iLenHOSTNAME < CONF_HOSTNAME_BUFSIZE)
        {
            pThis->pszHOSTNAME = pThis->szHOSTNAME;
        }
        else if ((pThis->pszHOSTNAME =
                      (uchar*)malloc(pThis->iLenHOSTNAME + 1)) == NULL)
        {
            pThis->pszHOSTNAME = pThis->szHOSTNAME;
            pThis->iLenHOSTNAME = CONF_HOSTNAME_BUFSIZE - 1;
        }
        memcpy(pThis->pszHOSTNAME, pszHOSTNAME, pThis->iLenHOSTNAME);
        pThis->pszHOSTNAME[pThis->iLenHOSTNAME] =
            '\0'; 
    }
void MsgSetHOSTNAME ( smsg_t * pThis , const uchar * pszHOSTNAME , const int lenHOSTNAME ) { assert ( pThis != NULL ) ; freeHOSTNAME ( pThis ) ; pThis -> iLenHOSTNAME = lenHOSTNAME ; if ( pThis -> iLenHOSTNAME < CONF_HOSTNAME_BUFSIZE ) { pThis -> pszHOSTNAME = pThis -> szHOSTNAME ; } else if ( ( pThis -> pszHOSTNAME = ( uchar * ) malloc ( pThis -> iLenHOSTNAME + 1 ) ) == NULL ) { pThis -> pszHOSTNAME = pThis -> szHOSTNAME ; pThis -> iLenHOSTNAME = CONF_HOSTNAME_BUFSIZE - 1 ; } memcpy ( pThis -> pszHOSTNAME , pszHOSTNAME , pThis -> iLenHOSTNAME ) ; pThis -> pszHOSTNAME [ pThis -> iLenHOSTNAME ] = ' \0 ' ; }
rgerhards 2004-11-09: set HOSTNAME in msg object
 rgerhards, 2007-06-21:
 Does not return anything.
rgerhards 2004 - 11 - 09 : set HOSTNAME in msg object rgerhards 2007 - 06 - 21 : Does not return anything .
/* small enough: use fixed buffer (faster!) */ /* truncate message, better than completely loosing it... */ /* this also works with truncation! */