summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--vp9/common/vp9_frame_buffers.c12
-rw-r--r--vp9/vp9_dx_iface.c4
-rw-r--r--vpx_mem/vpx_mem.c32
-rw-r--r--vpx_mem/vpx_mem.h1
4 files changed, 7 insertions, 42 deletions
diff --git a/vp9/common/vp9_frame_buffers.c b/vp9/common/vp9_frame_buffers.c
index efcf2bf88..a254e79d2 100644
--- a/vp9/common/vp9_frame_buffers.c
+++ b/vp9/common/vp9_frame_buffers.c
@@ -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;
}
diff --git a/vp9/vp9_dx_iface.c b/vp9/vp9_dx_iface.c
index 3b5dc3dda..4a1ebbc8c 100644
--- a/vp9/vp9_dx_iface.c
+++ b/vp9/vp9_dx_iface.c
@@ -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;
diff --git a/vpx_mem/vpx_mem.c b/vpx_mem/vpx_mem.c
index c94ed52d1..a9be08680 100644
--- a/vpx_mem/vpx_mem.c
+++ b/vpx_mem/vpx_mem.c
@@ -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);
diff --git a/vpx_mem/vpx_mem.h b/vpx_mem/vpx_mem.h
index c14f288b8..733aff488 100644
--- a/vpx_mem/vpx_mem.h
+++ b/vpx_mem/vpx_mem.h
@@ -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