michael@0: /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #include "nsXPCOM.h" michael@0: #include "nsMemory.h" michael@0: #include "nsIMemory.h" michael@0: #include "nsXPCOMPrivate.h" michael@0: #include "nsDebug.h" michael@0: #include "nsISupportsUtils.h" michael@0: #include "nsCOMPtr.h" michael@0: michael@0: //////////////////////////////////////////////////////////////////////////////// michael@0: // nsMemory static helper routines michael@0: michael@0: NS_COM_GLUE nsresult michael@0: nsMemory::HeapMinimize(bool aImmediate) michael@0: { michael@0: nsCOMPtr mem; michael@0: nsresult rv = NS_GetMemoryManager(getter_AddRefs(mem)); michael@0: if (NS_WARN_IF(NS_FAILED(rv))) michael@0: return rv; michael@0: michael@0: return mem->HeapMinimize(aImmediate); michael@0: } michael@0: michael@0: NS_COM_GLUE void* michael@0: nsMemory::Clone(const void* ptr, size_t size) michael@0: { michael@0: void* newPtr = NS_Alloc(size); michael@0: if (newPtr) michael@0: memcpy(newPtr, ptr, size); michael@0: return newPtr; michael@0: } michael@0: michael@0: NS_COM_GLUE nsIMemory* michael@0: nsMemory::GetGlobalMemoryService() michael@0: { michael@0: nsIMemory* mem; michael@0: nsresult rv = NS_GetMemoryManager(&mem); michael@0: if (NS_FAILED(rv)) return nullptr; michael@0: michael@0: return mem; michael@0: } michael@0: michael@0: //---------------------------------------------------------------------- michael@0: