Bug 1032573 part 4 - Add AnimationTimeline::ToTimelineTime helper method; r=dbaron
[gecko.git] / media / libogg / memory-reporting.patch
blob2a69da4d459e7f9ce1b9ecd88b84382bdd6dde6a
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
9 --- include/ogg/ogg.h
10 +++ include/ogg/ogg.h
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);
20 #ifdef __cplusplus
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
26 @@ -17,12 +17,33 @@
27 #ifndef _OS_TYPES_H
28 #define _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
36 +#include <stddef.h>
38 +/* We indirect mallocs through settable-at-runtime functions to accommodate
39 + memory reporting in the browser. */
41 +#ifdef __cplusplus
42 +extern "C" {
43 +#endif
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;
55 +#ifdef __cplusplus
57 +#endif
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
64 #if defined(_WIN32)
66 diff --git a/media/libogg/src/ogg_alloc.c b/media/libogg/src/ogg_alloc.c
67 new file mode 100644
68 index 0000000..4238d7b
69 --- /dev/null
70 +++ src/ogg_alloc.c
71 @@ -0,0 +1,31 @@
72 +/********************************************************************
73 + * *
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. *
78 + * *
79 + * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2002 *
80 + * by the Xiph.Org Foundation http://www.xiph.org/ *
81 + * *
82 + *********************************************************************/
84 +#include <stdlib.h>
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;
92 +void
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;