diff options
author | James Zern <jzern@google.com> | 2015-04-16 15:44:18 -0700 |
---|---|---|
committer | Gerrit Code Review <gerrit@gerrit.golo.chromium.org> | 2015-04-22 13:11:07 -0700 |
commit | 4feae6791c0da9535a1c4c347e473ebc996c9d39 (patch) | |
tree | a91534d0533fa367aa0a58d7da7e8e8537df152b /vpx_mem | |
parent | 4659e3644f5d14c3cf76dd2b2cbe9fb4d748495f (diff) | |
download | libvpx-4feae6791c0da9535a1c4c347e473ebc996c9d39.tar.gz |
vpx_mem: remove global function pointer
vestigial.
Change-Id: I11389f660d0c5db8fa48bd355cbc3223fc3bcabb
Diffstat (limited to 'vpx_mem')
-rw-r--r-- | vpx_mem/include/vpx_mem_intrnl.h | 4 | ||||
-rw-r--r-- | vpx_mem/vpx_mem.c | 104 | ||||
-rw-r--r-- | vpx_mem/vpx_mem.h | 36 |
3 files changed, 7 insertions, 137 deletions
diff --git a/vpx_mem/include/vpx_mem_intrnl.h b/vpx_mem/include/vpx_mem_intrnl.h index 555995634..c4dd78550 100644 --- a/vpx_mem/include/vpx_mem_intrnl.h +++ b/vpx_mem/include/vpx_mem_intrnl.h @@ -13,10 +13,6 @@ #define VPX_MEM_INCLUDE_VPX_MEM_INTRNL_H_ #include "./vpx_config.h" -#ifndef USE_GLOBAL_FUNCTION_POINTERS -# define USE_GLOBAL_FUNCTION_POINTERS 0 /*use function pointers instead of compiled functions.*/ -#endif - #define ADDRESS_STORAGE_SIZE sizeof(size_t) #ifndef DEFAULT_ALIGNMENT diff --git a/vpx_mem/vpx_mem.c b/vpx_mem/vpx_mem.c index 5c0892e40..0eb3f7a40 100644 --- a/vpx_mem/vpx_mem.c +++ b/vpx_mem/vpx_mem.c @@ -18,45 +18,11 @@ #include "include/vpx_mem_intrnl.h" #include "vpx/vpx_integer.h" -#if USE_GLOBAL_FUNCTION_POINTERS -struct GLOBAL_FUNC_POINTERS { - g_malloc_func g_malloc; - g_calloc_func g_calloc; - g_realloc_func g_realloc; - g_free_func g_free; - g_memcpy_func g_memcpy; - g_memset_func g_memset; - g_memmove_func g_memmove; -} *g_func = NULL; - -# define VPX_MALLOC_L g_func->g_malloc -# define VPX_REALLOC_L g_func->g_realloc -# define VPX_FREE_L g_func->g_free -# define VPX_MEMCPY_L g_func->g_memcpy -# define VPX_MEMSET_L g_func->g_memset -# define VPX_MEMMOVE_L g_func->g_memmove -#else -# define VPX_MALLOC_L malloc -# define VPX_REALLOC_L realloc -# define VPX_FREE_L free -# define VPX_MEMCPY_L memcpy -# define VPX_MEMSET_L memset -# define VPX_MEMMOVE_L memmove -#endif /* USE_GLOBAL_FUNCTION_POINTERS */ - -unsigned int vpx_mem_get_version() { - unsigned int ver = ((unsigned int)(unsigned char)VPX_MEM_VERSION_CHIEF << 24 | - (unsigned int)(unsigned char)VPX_MEM_VERSION_MAJOR << 16 | - (unsigned int)(unsigned char)VPX_MEM_VERSION_MINOR << 8 | - (unsigned int)(unsigned char)VPX_MEM_VERSION_PATCH); - return ver; -} - void *vpx_memalign(size_t align, size_t size) { void *addr, * x = NULL; - addr = VPX_MALLOC_L(size + align - 1 + ADDRESS_STORAGE_SIZE); + addr = malloc(size + align - 1 + ADDRESS_STORAGE_SIZE); if (addr) { x = align_addr((unsigned char *)addr + ADDRESS_STORAGE_SIZE, (int)align); @@ -77,7 +43,7 @@ void *vpx_calloc(size_t num, size_t size) { x = vpx_memalign(DEFAULT_ALIGNMENT, num * size); if (x) - VPX_MEMSET_L(x, 0, num * size); + memset(x, 0, num * size); return x; } @@ -103,7 +69,7 @@ void *vpx_realloc(void *memblk, size_t size) { addr = (void *)(((size_t *)memblk)[-1]); memblk = NULL; - new_addr = VPX_REALLOC_L(addr, size + align + ADDRESS_STORAGE_SIZE); + new_addr = realloc(addr, size + align + ADDRESS_STORAGE_SIZE); if (new_addr) { addr = new_addr; @@ -121,16 +87,16 @@ void *vpx_realloc(void *memblk, size_t size) { void vpx_free(void *memblk) { if (memblk) { void *addr = (void *)(((size_t *)memblk)[-1]); - VPX_FREE_L(addr); + free(addr); } } void *vpx_memcpy(void *dest, const void *source, size_t length) { - return VPX_MEMCPY_L(dest, source, length); + return memcpy(dest, source, length); } void *vpx_memset(void *dest, int val, size_t length) { - return VPX_MEMSET_L(dest, val, length); + return memset(dest, val, length); } #if CONFIG_VP9 && CONFIG_VP9_HIGHBITDEPTH @@ -145,61 +111,5 @@ void *vpx_memset16(void *dest, int val, size_t length) { #endif // CONFIG_VP9 && CONFIG_VP9_HIGHBITDEPTH void *vpx_memmove(void *dest, const void *src, size_t count) { - return VPX_MEMMOVE_L(dest, src, count); -} - -int vpx_mem_set_functions(g_malloc_func g_malloc_l -, g_calloc_func g_calloc_l -, g_realloc_func g_realloc_l -, g_free_func g_free_l -, g_memcpy_func g_memcpy_l -, g_memset_func g_memset_l -, g_memmove_func g_memmove_l) { -#if USE_GLOBAL_FUNCTION_POINTERS - - /* If use global functions is turned on then the - application must set the global functions before - it does anything else or vpx_mem will have - unpredictable results. */ - if (!g_func) { - g_func = (struct GLOBAL_FUNC_POINTERS *) - g_malloc_l(sizeof(struct GLOBAL_FUNC_POINTERS)); - - if (!g_func) { - return -1; - } - } - - g_func->g_malloc = g_malloc_l; - g_func->g_calloc = g_calloc_l; - g_func->g_realloc = g_realloc_l; - g_func->g_free = g_free_l; - g_func->g_memcpy = g_memcpy_l; - g_func->g_memset = g_memset_l; - g_func->g_memmove = g_memmove_l; - - return 0; -#else - (void)g_malloc_l; - (void)g_calloc_l; - (void)g_realloc_l; - (void)g_free_l; - (void)g_memcpy_l; - (void)g_memset_l; - (void)g_memmove_l; - return -1; -#endif -} - -int vpx_mem_unset_functions() { -#if USE_GLOBAL_FUNCTION_POINTERS - - if (g_func) { - g_free_func temp_free = g_func->g_free; - temp_free(g_func); - g_func = NULL; - } - -#endif - return 0; + return memmove(dest, src, count); } diff --git a/vpx_mem/vpx_mem.h b/vpx_mem/vpx_mem.h index 4da606f1f..f6876d63e 100644 --- a/vpx_mem/vpx_mem.h +++ b/vpx_mem/vpx_mem.h @@ -17,15 +17,6 @@ # include <lddk.h> #endif -/* vpx_mem version info */ -#define vpx_mem_version "2.2.1.5" - -#define VPX_MEM_VERSION_CHIEF 2 -#define VPX_MEM_VERSION_MAJOR 2 -#define VPX_MEM_VERSION_MINOR 1 -#define VPX_MEM_VERSION_PATCH 5 -/* end - vpx_mem version info */ - #ifndef REPLACE_BUILTIN_FUNCTIONS # define REPLACE_BUILTIN_FUNCTIONS 0 /* replace builtin functions with their vpx_ equivalents */ @@ -38,14 +29,6 @@ vpx_ equivalents */ extern "C" { #endif - /* - vpx_mem_get_version() - provided for runtime version checking. Returns an unsigned int of the form - CHIEF | MAJOR | MINOR | PATCH, where the chief version number is the high - order byte. - */ - unsigned int vpx_mem_get_version(void); - void *vpx_memalign(size_t align, size_t size); void *vpx_malloc(size_t size); void *vpx_calloc(size_t num, size_t size); @@ -59,25 +42,6 @@ extern "C" { #endif void *vpx_memmove(void *dest, const void *src, size_t count); - /* Wrappers to standard library functions. */ - typedef void *(* g_malloc_func)(size_t); - typedef void *(* g_calloc_func)(size_t, size_t); - typedef void *(* g_realloc_func)(void *, size_t); - typedef void (* g_free_func)(void *); - typedef void *(* g_memcpy_func)(void *, const void *, size_t); - typedef void *(* g_memset_func)(void *, int, size_t); - typedef void *(* g_memmove_func)(void *, const void *, size_t); - - int vpx_mem_set_functions(g_malloc_func g_malloc_l -, g_calloc_func g_calloc_l -, g_realloc_func g_realloc_l -, g_free_func g_free_l -, g_memcpy_func g_memcpy_l -, g_memset_func g_memset_l -, g_memmove_func g_memmove_l); - int vpx_mem_unset_functions(void); - - /* some defines for backward compatibility */ #define DMEM_GENERAL 0 |