1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim:set ts=2 sw=2 sts=2 et cindent: */
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/. */
7 #include "PHCManager.h"
9 #include "replace_malloc_bridge.h"
10 #include "mozilla/Preferences.h"
11 #include "mozilla/StaticPrefs_memory.h"
17 static const char kPHCPref
[] = "memory.phc.enabled";
19 static PHCState
GetPHCStateFromPref() {
20 return StaticPrefs::memory_phc_enabled() ? Enabled
: OnlyFree
;
23 static void PrefChangeCallback(const char* aPrefName
, void* aNull
) {
24 MOZ_ASSERT(0 == strcmp(aPrefName
, kPHCPref
));
26 ReplaceMalloc::SetPHCState(GetPHCStateFromPref());
30 ReplaceMalloc::SetPHCState(GetPHCStateFromPref());
32 Preferences::RegisterCallback(PrefChangeCallback
, kPHCPref
);
35 }; // namespace mozilla