Debian Codegraph @

js/src/util/AllocationLogging.cpp

raw
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 "js/AllocationLogging.h"
8
9 #include "mozilla/Assertions.h" // MOZ_ASSERT
10
11 static JS::LogCtorDtor sLogCtor = nullptr;
12 static JS::LogCtorDtor sLogDtor = nullptr;
13
14 void JS::SetLogCtorDtorFunctions(LogCtorDtor ctor, LogCtorDtor dtor) {
15 MOZ_ASSERT(!sLogCtor && !sLogDtor);
16 MOZ_ASSERT(ctor && dtor);
17 sLogCtor = ctor;
18 sLogDtor = dtor;
19 }
20
21 void JS::LogCtor(void* self, const char* type, uint32_t sz) {
22 if (LogCtorDtor fun = sLogCtor) {
23 fun(self, type, sz);
24 }
25 }
26
27 void JS::LogDtor(void* self, const char* type, uint32_t sz) {
28 if (LogCtorDtor fun = sLogDtor) {
29 fun(self, type, sz);
30 }
31 }