1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/media/libogg/memory-reporting.patch Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,102 @@ 1.4 +commit 16362f7dc755d9a2cfb8df06db74a16fcc97e495 1.5 +Author: Nathan Froyd <froydnj@mozilla.com> 1.6 +Date: Wed Mar 5 10:58:29 2014 -0500 1.7 + 1.8 + Bug 677653 - part 1 - indirect libogg memory allocations through variables 1.9 + 1.10 +diff --git a/media/libogg/include/ogg/ogg.h b/media/libogg/include/ogg/ogg.h 1.11 +index cea4ebe..cebe38e 100644 1.12 +--- include/ogg/ogg.h 1.13 ++++ include/ogg/ogg.h 1.14 +@@ -202,6 +202,10 @@ extern int ogg_page_packets(const ogg_page *og); 1.15 + 1.16 + extern void ogg_packet_clear(ogg_packet *op); 1.17 + 1.18 ++extern void ogg_set_mem_functions(ogg_malloc_function_type *malloc_func, 1.19 ++ ogg_calloc_function_type *calloc_func, 1.20 ++ ogg_realloc_function_type *realloc_func, 1.21 ++ ogg_free_function_type *free_func); 1.22 + 1.23 + #ifdef __cplusplus 1.24 + } 1.25 +diff --git a/media/libogg/include/ogg/os_types.h b/media/libogg/include/ogg/os_types.h 1.26 +index 2c75a20..83ed732 100644 1.27 +--- include/ogg/os_types.h 1.28 ++++ include/ogg/os_types.h 1.29 +@@ -17,12 +17,33 @@ 1.30 + #ifndef _OS_TYPES_H 1.31 + #define _OS_TYPES_H 1.32 + 1.33 +-/* make it easy on the folks that want to compile the libs with a 1.34 +- different malloc than stdlib */ 1.35 +-#define _ogg_malloc malloc 1.36 +-#define _ogg_calloc calloc 1.37 +-#define _ogg_realloc realloc 1.38 +-#define _ogg_free free 1.39 ++#include <stddef.h> 1.40 ++ 1.41 ++/* We indirect mallocs through settable-at-runtime functions to accommodate 1.42 ++ memory reporting in the browser. */ 1.43 ++ 1.44 ++#ifdef __cplusplus 1.45 ++extern "C" { 1.46 ++#endif 1.47 ++ 1.48 ++typedef void* (ogg_malloc_function_type)(size_t); 1.49 ++typedef void* (ogg_calloc_function_type)(size_t, size_t); 1.50 ++typedef void* (ogg_realloc_function_type)(void*, size_t); 1.51 ++typedef void (ogg_free_function_type)(void*); 1.52 ++ 1.53 ++extern ogg_malloc_function_type *ogg_malloc_func; 1.54 ++extern ogg_calloc_function_type *ogg_calloc_func; 1.55 ++extern ogg_realloc_function_type *ogg_realloc_func; 1.56 ++extern ogg_free_function_type *ogg_free_func; 1.57 ++ 1.58 ++#ifdef __cplusplus 1.59 ++} 1.60 ++#endif 1.61 ++ 1.62 ++#define _ogg_malloc ogg_malloc_func 1.63 ++#define _ogg_calloc ogg_calloc_func 1.64 ++#define _ogg_realloc ogg_realloc_func 1.65 ++#define _ogg_free ogg_free_func 1.66 + 1.67 + #if defined(_WIN32) 1.68 + 1.69 +diff --git a/media/libogg/src/ogg_alloc.c b/media/libogg/src/ogg_alloc.c 1.70 +new file mode 100644 1.71 +index 0000000..4238d7b 1.72 +--- /dev/null 1.73 ++++ src/ogg_alloc.c 1.74 +@@ -0,0 +1,31 @@ 1.75 ++/******************************************************************** 1.76 ++ * * 1.77 ++ * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * 1.78 ++ * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * 1.79 ++ * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * 1.80 ++ * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * 1.81 ++ * * 1.82 ++ * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2002 * 1.83 ++ * by the Xiph.Org Foundation http://www.xiph.org/ * 1.84 ++ * * 1.85 ++ *********************************************************************/ 1.86 ++ 1.87 ++#include <stdlib.h> 1.88 ++#include "ogg/os_types.h" 1.89 ++ 1.90 ++ogg_malloc_function_type *ogg_malloc_func = malloc; 1.91 ++ogg_calloc_function_type *ogg_calloc_func = calloc; 1.92 ++ogg_realloc_function_type *ogg_realloc_func = realloc; 1.93 ++ogg_free_function_type *ogg_free_func = free; 1.94 ++ 1.95 ++void 1.96 ++ogg_set_mem_functions(ogg_malloc_function_type *malloc_func, 1.97 ++ ogg_calloc_function_type *calloc_func, 1.98 ++ ogg_realloc_function_type *realloc_func, 1.99 ++ ogg_free_function_type *free_func) 1.100 ++{ 1.101 ++ ogg_malloc_func = malloc_func; 1.102 ++ ogg_calloc_func = calloc_func; 1.103 ++ ogg_realloc_func = realloc_func; 1.104 ++ ogg_free_func = free_func; 1.105 ++}