Remove vpx_realloc()
It only handles the realloc constraint (preserving low elements) by serendipity, and we don't actually rely on that behavior anyway. Meanwhile the calls may do extra copying that gets immediately clobbered by the callers. Change-Id: I8dfa89e4a81084b084889c27bd272fdf85184e8d
This commit is contained in:
parent
a7456144ce
commit
3063c37600
@ -52,14 +52,12 @@ int vp9_get_frame_buffer(void *cb_priv, size_t min_size,
|
||||
if (i == int_fb_list->num_internal_frame_buffers) return -1;
|
||||
|
||||
if (int_fb_list->int_fb[i].size < min_size) {
|
||||
int_fb_list->int_fb[i].data =
|
||||
(uint8_t *)vpx_realloc(int_fb_list->int_fb[i].data, min_size);
|
||||
if (!int_fb_list->int_fb[i].data) return -1;
|
||||
|
||||
// This memset is needed for fixing valgrind error from C loop filter
|
||||
vpx_free(int_fb_list->int_fb[i].data);
|
||||
// The data must be zeroed to fix a valgrind error from the C loop filter
|
||||
// due to access uninitialized memory in frame border. It could be
|
||||
// removed if border is totally removed.
|
||||
memset(int_fb_list->int_fb[i].data, 0, min_size);
|
||||
// skipped if border were totally removed.
|
||||
int_fb_list->int_fb[i].data = (uint8_t *)vpx_calloc(1, min_size);
|
||||
if (!int_fb_list->int_fb[i].data) return -1;
|
||||
int_fb_list->int_fb[i].size = min_size;
|
||||
}
|
||||
|
||||
|
@ -467,8 +467,8 @@ static vpx_codec_err_t decode_one(vpx_codec_alg_priv_t *ctx,
|
||||
// as the size of the first intra frame be better? This will
|
||||
// avoid too many deallocate and allocate.
|
||||
if (frame_worker_data->scratch_buffer_size < data_sz) {
|
||||
frame_worker_data->scratch_buffer =
|
||||
(uint8_t *)vpx_realloc(frame_worker_data->scratch_buffer, data_sz);
|
||||
vpx_free(frame_worker_data->scratch_buffer);
|
||||
frame_worker_data->scratch_buffer = (uint8_t *)vpx_malloc(data_sz);
|
||||
if (frame_worker_data->scratch_buffer == NULL) {
|
||||
set_error_detail(ctx, "Failed to reallocate scratch buffer");
|
||||
return VPX_CODEC_MEM_ERROR;
|
||||
|
@ -76,38 +76,6 @@ void *vpx_calloc(size_t num, size_t size) {
|
||||
return x;
|
||||
}
|
||||
|
||||
void *vpx_realloc(void *memblk, size_t size) {
|
||||
void *new_addr = NULL;
|
||||
|
||||
/*
|
||||
The realloc() function changes the size of the object pointed to by
|
||||
ptr to the size specified by size, and returns a pointer to the
|
||||
possibly moved block. The contents are unchanged up to the lesser
|
||||
of the new and old sizes. If ptr is null, realloc() behaves like
|
||||
malloc() for the specified size. If size is zero (0) and ptr is
|
||||
not a null pointer, the object pointed to is freed.
|
||||
*/
|
||||
if (!memblk)
|
||||
new_addr = vpx_malloc(size);
|
||||
else if (!size)
|
||||
vpx_free(memblk);
|
||||
else {
|
||||
void *addr = get_actual_malloc_address(memblk);
|
||||
const uint64_t aligned_size =
|
||||
get_aligned_malloc_size(size, DEFAULT_ALIGNMENT);
|
||||
if (!check_size_argument_overflow(1, aligned_size)) return NULL;
|
||||
|
||||
addr = realloc(addr, (size_t)aligned_size);
|
||||
if (addr) {
|
||||
new_addr = align_addr((unsigned char *)addr + ADDRESS_STORAGE_SIZE,
|
||||
DEFAULT_ALIGNMENT);
|
||||
set_actual_malloc_address(new_addr, addr);
|
||||
}
|
||||
}
|
||||
|
||||
return new_addr;
|
||||
}
|
||||
|
||||
void vpx_free(void *memblk) {
|
||||
if (memblk) {
|
||||
void *addr = get_actual_malloc_address(memblk);
|
||||
|
@ -26,7 +26,6 @@ extern "C" {
|
||||
void *vpx_memalign(size_t align, size_t size);
|
||||
void *vpx_malloc(size_t size);
|
||||
void *vpx_calloc(size_t num, size_t size);
|
||||
void *vpx_realloc(void *memblk, size_t size);
|
||||
void vpx_free(void *memblk);
|
||||
|
||||
#if CONFIG_VP9_HIGHBITDEPTH
|
||||
|
Loading…
Reference in New Issue
Block a user