1 commit 16362f7dc755d9a2cfb8df06db74a16fcc97e495
2 Author: Nathan Froyd <froydnj@mozilla.com>
3 Date: Wed Mar 5 10:58:29 2014 -0500
5 Bug 677653 - part 1 - indirect libogg memory allocations through variables
7 diff --git a/media/libogg/include/ogg/ogg.h b/media/libogg/include/ogg/ogg.h
8 index cea4ebe..cebe38e 100644
11 @@ -202,6 +202,10 @@ extern int ogg_page_packets(const ogg_page *og);
13 extern void ogg_packet_clear(ogg_packet *op);
15 +extern void ogg_set_mem_functions(ogg_malloc_function_type *malloc_func,
16 + ogg_calloc_function_type *calloc_func,
17 + ogg_realloc_function_type *realloc_func,
18 + ogg_free_function_type *free_func);
22 diff --git a/media/libogg/include/ogg/os_types.h b/media/libogg/include/ogg/os_types.h
23 index 2c75a20..83ed732 100644
24 --- include/ogg/os_types.h
25 +++ include/ogg/os_types.h
30 -/* make it easy on the folks that want to compile the libs with a
31 - different malloc than stdlib */
32 -#define _ogg_malloc malloc
33 -#define _ogg_calloc calloc
34 -#define _ogg_realloc realloc
35 -#define _ogg_free free
38 +/* We indirect mallocs through settable-at-runtime functions to accommodate
39 + memory reporting in the browser. */
45 +typedef void* (ogg_malloc_function_type)(size_t);
46 +typedef void* (ogg_calloc_function_type)(size_t, size_t);
47 +typedef void* (ogg_realloc_function_type)(void*, size_t);
48 +typedef void (ogg_free_function_type)(void*);
50 +extern ogg_malloc_function_type *ogg_malloc_func;
51 +extern ogg_calloc_function_type *ogg_calloc_func;
52 +extern ogg_realloc_function_type *ogg_realloc_func;
53 +extern ogg_free_function_type *ogg_free_func;
59 +#define _ogg_malloc ogg_malloc_func
60 +#define _ogg_calloc ogg_calloc_func
61 +#define _ogg_realloc ogg_realloc_func
62 +#define _ogg_free ogg_free_func
66 diff --git a/media/libogg/src/ogg_alloc.c b/media/libogg/src/ogg_alloc.c
68 index 0000000..4238d7b
72 +/********************************************************************
74 + * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. *
75 + * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS *
76 + * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
77 + * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
79 + * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2002 *
80 + * by the Xiph.Org Foundation http://www.xiph.org/ *
82 + *********************************************************************/
85 +#include "ogg/os_types.h"
87 +ogg_malloc_function_type *ogg_malloc_func = malloc;
88 +ogg_calloc_function_type *ogg_calloc_func = calloc;
89 +ogg_realloc_function_type *ogg_realloc_func = realloc;
90 +ogg_free_function_type *ogg_free_func = free;
93 +ogg_set_mem_functions(ogg_malloc_function_type *malloc_func,
94 + ogg_calloc_function_type *calloc_func,
95 + ogg_realloc_function_type *realloc_func,
96 + ogg_free_function_type *free_func)
98 + ogg_malloc_func = malloc_func;
99 + ogg_calloc_func = calloc_func;
100 + ogg_realloc_func = realloc_func;
101 + ogg_free_func = free_func;