gfx/skia/trunk/src/ports/SkMemory_malloc.cpp

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

     2 /*
     3  * Copyright 2011 Google Inc.
     4  *
     5  * Use of this source code is governed by a BSD-style license that can be
     6  * found in the LICENSE file.
     7  */
     8 #include "SkTypes.h"
     9 #include <stdio.h>
    10 #include <stdlib.h>
    12 static inline void* throw_on_failure(size_t size, void* p) {
    13     if (size > 0 && p == NULL) {
    14         // If we've got a NULL here, the only reason we should have failed is running out of RAM.
    15         sk_out_of_memory();
    16     }
    17     return p;
    18 }
    20 void sk_throw() {
    21     SkDEBUGFAIL("sk_throw");
    22     abort();
    23 }
    25 void sk_out_of_memory(void) {
    26     SkDEBUGFAIL("sk_out_of_memory");
    27     abort();
    28 }
    30 void* sk_malloc_throw(size_t size) {
    31     return sk_malloc_flags(size, SK_MALLOC_THROW);
    32 }
    34 void* sk_realloc_throw(void* addr, size_t size) {
    35     return throw_on_failure(size, realloc(addr, size));
    36 }
    38 void sk_free(void* p) {
    39     if (p) {
    40         free(p);
    41     }
    42 }
    44 void* sk_malloc_flags(size_t size, unsigned flags) {
    45     void* p = malloc(size);
    46     if (flags & SK_MALLOC_THROW) {
    47         return throw_on_failure(size, p);
    48     } else {
    49         return p;
    50     }
    51 }
    53 void* sk_calloc(size_t size) {
    54     return calloc(size, 1);
    55 }
    57 void* sk_calloc_throw(size_t size) {
    58     return throw_on_failure(size, sk_calloc(size));
    59 }

mercurial