Use av_malloc instead of plain malloc where appropriate