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/. */
8 #include "nsXPCOMPrivate.h"
10 #include "nsISupportsUtils.h"
13 ////////////////////////////////////////////////////////////////////////////////
14 // nsMemory static helper routines
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
);
27 nsMemory::Clone(const void* ptr
, size_t size
)
29 void* newPtr
= NS_Alloc(size
);
31 memcpy(newPtr
, ptr
, size
);
35 NS_COM_GLUE nsIMemory
*
36 nsMemory::GetGlobalMemoryService()
39 nsresult rv
= NS_GetMemoryManager(&mem
);
40 if (NS_FAILED(rv
)) return nullptr;
45 //----------------------------------------------------------------------