[Libav-user] g++ 4.7.2 fails to compile av_err2str
Nicolas George
nicolas.george at normalesup.org
Mon Jan 14 17:49:13 CET 2013
Le quintidi 25 nivôse, an CCXXI, Alex Cohn a écrit :
> Yes, alloca() should be OK. Now that I think about it, that's right:
> it is compatible with C, too.
I am far from sure that alloca() exists in all supported C compilers.
> But Microsoft compiler only recognizes
> _alloca().
There you are.
There is another problem with alloca(): the scope of the allocation is
per function, while the scope of a compound literal, as used by the macro
currently, is per block.
That means that the following function:
void encode(void)
{
while (packet = read_packet()) {
if ((ret = avcodec_decode_video2(avc, frame, &out, packet)) < 0) {
fprintf(stderr, "Error decoding: %s\n", av_err2str(ret));
continue;
}
if (out)
output_frame(frame);
}
}
with the current macro, works as expected, whereas if the macro were based
on alloca(), the error strings would stay allocated until the loop is
completed. That is a memory leak. Probably not terrible, but still a leak.
Regards,
--
Nicolas George
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/libav-user/attachments/20130114/73b177b9/attachment.asc>
More information about the Libav-user
mailing list