[FFmpeg-devel] [RFC] Public API for RC4 and DES
Marc Mason
mpeg.blue
Mon Feb 2 10:59:16 CET 2009
Marc Mason wrote:
> Michael Niedermayer wrote:
>
>> Reimar D?ffinger wrote:
>>
>>> + rc4 = av_malloc(av_rc4_size);
>> uint8_t rc4v[av_rc4_size];
>> struct AVRC4 *rc4= (void*)rc4v;
>
> Because allocation on the stack is expected to be faster than allocation
> on the heap?
>
> Would it make sense to use platform-dependent routines, such as alloca?
I was asking in the general case. It also occurred to me that C99
mentions variable length arrays.
In this particular case, AFAIU, rc4 is malloc()ed at the start of
ff_asfcrypt_dec() and then free()d at the end of the same invocation?
struct AVRC4 *rc4;
[...]
rc4 = av_malloc(av_rc4_size);
/* pass rc4 around */
[...]
av_free(rc4);
Then, why not just declare rc4 on the stack, and pass its address?
struct AVRC4 rc4;
[...]
/* rc4 = av_malloc(av_rc4_size); UNNECESSARY */
/* pass &rc4 around */
[...]
/* av_free(rc4); UNNECESSARY */
I must be missing something?
--
Regards.
More information about the ffmpeg-devel
mailing list