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
signature.asc
Description: Digital signature
_______________________________________________ Libav-user mailing list [email protected] http://ffmpeg.org/mailman/listinfo/libav-user
