[Libav-user] Questionable libav code

Ratin ratin3 at gmail.com
Tue Feb 2 23:30:08 CET 2016


libavcodec has codes like this one :

static AVPacket *add_to_pktbuf(AVPacketList **packet_buffer, AVPacket *pkt,
                               AVPacketList **plast_pktl)
{
    AVPacketList *pktl = av_mallocz(sizeof(AVPacketList));
    if (!pktl)
        return NULL;

    if (*packet_buffer)
        (*plast_pktl)->next = pktl;
    else
        *packet_buffer = pktl;

    /* Add the packet in the buffered packet list. */
    *plast_pktl = pktl;
    pktl->pkt   = *pkt; <===========================
    return &pktl->pkt;
}


Here a struct variable is meant to be copied over via assignment, is that
100% correct to always work the way was intended?  Given that the struct
pkt is a big struct which has raw bytes that are malloc'd. I was always
trained to avoid such struct assignment operations. What do people think?

Ratin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://ffmpeg.org/pipermail/libav-user/attachments/20160202/f35958d6/attachment.html>


More information about the Libav-user mailing list