[MPlayer-dev-eng] Re: [PATCH] Save memory in demux_rtp.cpp
Nico Sabbi
nicola_sabbi at fastwebnet.it
Mon Feb 26 23:06:19 CET 2007
Carl Eugen Hoyos wrote:
> Nico Sabbi <nicola_sabbi <at> fastwebnet.it> writes:
>
> [...]
>
>
>>> void ReadBufferQueue::savePendingBuffer(demux_packet_t* dp) {
>>>+ resize_demux_packet(dp, dp->len);
>>> // Keep this buffer around, until MPlayer asks for it later:
>>> if (pendingDPTail == NULL) {
>>> pendingDPHead = pendingDPTail = dp;
>>
>>dp->len is already the actual size of the packet, unless you call it
>>with 0. Is it the case?
>
>
> The packet was allocated with
> dp = new_demux_packet(MAX_RTP_FRAME_SIZE);
> but the patch resizes it to its actual size.
>
> Carl Eugen
>
>
new_demux_packet() and resize_demux_packet() both store the length of
the buffer in dp->len, so at any time dp->len is the amount of memory
allocated;
resize_demux_packet(dp, dp->len); is equivalent to a no-op, as you can
see:
inline static void resize_demux_packet(demux_packet_t* dp, int len)
{
if(len > 0)
{
dp->buffer=(unsigned char *)realloc(dp->buffer,len+8);
}
else
{
if(dp->buffer) free(dp->buffer);
dp->buffer=NULL;
}
dp->len=len;
if (dp->buffer)
memset(dp->buffer + len, 0, 8);
else
dp->len = 0;
}
I still don't see the usefulness of this patch, so show me if (and
where) the dp is tampered with, please
--
"Without a frontend, mplayer is useless" - someone in mplayer-users
More information about the MPlayer-dev-eng
mailing list