首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >av_fast_realloc比av_realloc快吗?

av_fast_realloc比av_realloc快吗?
EN

Stack Overflow用户
提问于 2018-01-17 16:58:40
回答 1查看 53关注 0票数 1

我应该用它来代替吗?看起来只是更紧凑而已。

https://ffmpeg.org/doxygen/trunk/group__lavu__mem__funcs.html

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-01-17 22:29:49

这是最新版本的整个函数,它实际上调用了av_realloc,但首先检查提供的缓冲区是否像文档中所说的足够大,如果足够大,则不执行av_realloc,实际上,除了在这种情况下返回相同的缓冲区之外,它不做任何其他事情。希望这能有所帮助。

代码语言:javascript
复制
void *av_fast_realloc(void *ptr, unsigned int *size, size_t min_size)
{
    if (min_size <= *size)
        return ptr;

    if (min_size > max_alloc_size - 32) {
        *size = 0;
        return NULL;
    }

    min_size = FFMIN(max_alloc_size - 32, FFMAX(min_size + min_size / 16 + 32, min_size));

    ptr = av_realloc(ptr, min_size);
    /* we could set this to the unmodified min_size but this is safer
     * if the user lost the ptr and uses NULL now
     */
    if (!ptr)
        min_size = 0;

    *size = min_size;

    return ptr;
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/48297132

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档