gfx/skia/patches/archive/0017-Bug-740194-SkMemory-mozalloc.patch

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 commit 5786f516119bcb677510f3c9256b870c3b5616c8
michael@0 2 Author: George Wright <gwright@mozilla.com>
michael@0 3 Date: Wed Aug 15 23:51:34 2012 -0400
michael@0 4
michael@0 5 Bug 740194 - [Skia] Implement a version of SkMemory for Mozilla that uses the infallible mozalloc allocators r=cjones
michael@0 6
michael@0 7 diff --git a/gfx/skia/include/config/SkUserConfig.h b/gfx/skia/include/config/SkUserConfig.h
michael@0 8 index f98ba85..17be191 100644
michael@0 9 --- a/gfx/skia/include/config/SkUserConfig.h
michael@0 10 +++ b/gfx/skia/include/config/SkUserConfig.h
michael@0 11 @@ -35,6 +35,16 @@
michael@0 12 commented out, so including it will have no effect.
michael@0 13 */
michael@0 14
michael@0 15 +/*
michael@0 16 + Override new/delete with Mozilla's allocator, mozalloc
michael@0 17 +
michael@0 18 + Ideally we shouldn't need to do this here, but until
michael@0 19 + http://code.google.com/p/skia/issues/detail?id=598 is fixed
michael@0 20 + we need to include this here to override operator new and delete
michael@0 21 +*/
michael@0 22 +
michael@0 23 +#include "mozilla/mozalloc.h"
michael@0 24 +
michael@0 25 ///////////////////////////////////////////////////////////////////////////////
michael@0 26
michael@0 27 /* Scalars (the fractional value type in skia) can be implemented either as
michael@0 28 diff --git a/gfx/skia/src/ports/SkMemory_mozalloc.cpp b/gfx/skia/src/ports/SkMemory_mozalloc.cpp
michael@0 29 new file mode 100644
michael@0 30 index 0000000..1f16ee5
michael@0 31 --- /dev/null
michael@0 32 +++ b/gfx/skia/src/ports/SkMemory_mozalloc.cpp
michael@0 33 @@ -0,0 +1,40 @@
michael@0 34 +/*
michael@0 35 + * Copyright 2011 Google Inc.
michael@0 36 + * Copyright 2012 Mozilla Foundation
michael@0 37 + *
michael@0 38 + * Use of this source code is governed by a BSD-style license that can be
michael@0 39 + * found in the LICENSE file.
michael@0 40 + */
michael@0 41 +
michael@0 42 +#include "SkTypes.h"
michael@0 43 +
michael@0 44 +#include "mozilla/mozalloc.h"
michael@0 45 +#include "mozilla/mozalloc_abort.h"
michael@0 46 +#include "mozilla/mozalloc_oom.h"
michael@0 47 +
michael@0 48 +void sk_throw() {
michael@0 49 + SkDEBUGFAIL("sk_throw");
michael@0 50 + mozalloc_abort("Abort from sk_throw");
michael@0 51 +}
michael@0 52 +
michael@0 53 +void sk_out_of_memory(void) {
michael@0 54 + SkDEBUGFAIL("sk_out_of_memory");
michael@0 55 + mozalloc_handle_oom(0);
michael@0 56 +}
michael@0 57 +
michael@0 58 +void* sk_malloc_throw(size_t size) {
michael@0 59 + return sk_malloc_flags(size, SK_MALLOC_THROW);
michael@0 60 +}
michael@0 61 +
michael@0 62 +void* sk_realloc_throw(void* addr, size_t size) {
michael@0 63 + return moz_xrealloc(addr, size);
michael@0 64 +}
michael@0 65 +
michael@0 66 +void sk_free(void* p) {
michael@0 67 + moz_free(p);
michael@0 68 +}
michael@0 69 +
michael@0 70 +void* sk_malloc_flags(size_t size, unsigned flags) {
michael@0 71 + return (flags & SK_MALLOC_THROW) ? moz_xmalloc(size) : moz_malloc(size);
michael@0 72 +}
michael@0 73 +

mercurial