[FFmpeg-devel] [PATCH] av_malloc() workaround for QNX platform
mike.gorchak.qnx at gmail.com
Thu Feb 7 15:31:01 CET 2013
I've attached a patch for QNX which resolves issues of memalign() and
posix_memalign() functions. I know this looks like a dirty hack, but this
is the only way to workaround current issues.
By the way I have found a bug in the av_malloc() function when
CONFIG_MEMALIGN_HACK is used. I've tried it instead on QNX
instead of posix_memalign()/memaligh() functions. The code looks like:
ptr = malloc(size + ALIGN);
diff = ((~(long)ptr)&(ALIGN - 1)) + 1;
ptr = (char *)ptr + diff;
((char *)ptr)[-1] = diff;
After malloc() there is needed a check for ptr which can be ALREADY
aligned. In this case we have not to execute this line: ((char
*)ptr)[-1] = diff; which can cause a memory trashing. But better to
allocate (size+2*ALIGN) bytes and then move ptr forward for at least ALIGN
bytes to make sure that buffer has spare space for writting a 'diff'
Thanks in advance!
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 977 bytes
Desc: not available
More information about the ffmpeg-devel