tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

Fallback.cpp (1379B)


      1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
      2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
      3 /* This Source Code Form is subject to the terms of the Mozilla Public
      4 * License, v. 2.0. If a copy of the MPL was not distributed with this
      5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      6 
      7 #include "mozmemory.h"
      8 #include "mozjemalloc.h"
      9 
     10 #ifndef HAVE_MEMALIGN
     11 MOZ_MEMORY_API void* memalign(size_t aAlignment, size_t aSize) {
     12 #  ifdef XP_WIN
     13  return _aligned_malloc(aSize, aAlignment);
     14 #  else
     15  void* ret;
     16  if (posix_memalign(&ret, aAlignment, aSize) != 0) {
     17    return nullptr;
     18  }
     19  return ret;
     20 #  endif
     21 }
     22 #endif
     23 
     24 struct SystemMalloc {
     25 #define MALLOC_DECL(name, return_type, ...)                                \
     26  static inline return_type name(ARGS_HELPER(TYPED_ARGS, ##__VA_ARGS__)) { \
     27    return ::name(ARGS_HELPER(ARGS, ##__VA_ARGS__));                       \
     28  }
     29 #define MALLOC_FUNCS MALLOC_FUNCS_MALLOC_BASE
     30 #include "malloc_decls.h"
     31 };
     32 
     33 #define MALLOC_DECL(name, return_type, ...)                                   \
     34  MOZ_JEMALLOC_API return_type name(ARGS_HELPER(TYPED_ARGS, ##__VA_ARGS__)) { \
     35    return DummyArenaAllocator<SystemMalloc>::name(                           \
     36        ARGS_HELPER(ARGS, ##__VA_ARGS__));                                    \
     37  }
     38 #define MALLOC_FUNCS MALLOC_FUNCS_ARENA
     39 #include "malloc_decls.h"