Bug 895720 - Actually use the fuzz value.
[gecko.git] / xpcom / glue / nsMemory.cpp
bloba2790b74ba3ca20915863391700d4564544c2722
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #include "nsXPCOM.h"
7 #include "nsMemory.h"
8 #include "nsXPCOMPrivate.h"
9 #include "nsDebug.h"
10 #include "nsISupportsUtils.h"
11 #include "nsCOMPtr.h"
13 ////////////////////////////////////////////////////////////////////////////////
14 // nsMemory static helper routines
16 NS_COM_GLUE nsresult
17 nsMemory::HeapMinimize(bool aImmediate)
19 nsCOMPtr<nsIMemory> mem;
20 nsresult rv = NS_GetMemoryManager(getter_AddRefs(mem));
21 NS_ENSURE_SUCCESS(rv, rv);
23 return mem->HeapMinimize(aImmediate);
26 NS_COM_GLUE void*
27 nsMemory::Clone(const void* ptr, size_t size)
29 void* newPtr = NS_Alloc(size);
30 if (newPtr)
31 memcpy(newPtr, ptr, size);
32 return newPtr;
35 NS_COM_GLUE nsIMemory*
36 nsMemory::GetGlobalMemoryService()
38 nsIMemory* mem;
39 nsresult rv = NS_GetMemoryManager(&mem);
40 if (NS_FAILED(rv)) return nullptr;
42 return mem;
45 //----------------------------------------------------------------------