Newton Dynamics  4.00
dMemory.h
1 /* Copyright (c) <2003-2019> <Julio Jerez, Newton Game Dynamics>
2 *
3 * This software is provided 'as-is', without any express or implied
4 * warranty. In no event will the authors be held liable for any damages
5 * arising from the use of this software.
6 *
7 * Permission is granted to anyone to use this software for any purpose,
8 * including commercial applications, and to alter it and redistribute it
9 * freely, subject to the following restrictions:
10 *
11 * 1. The origin of this software must not be misrepresented; you must not
12 * claim that you wrote the original software. If you use this software
13 * in a product, an acknowledgment in the product documentation would be
14 * appreciated but is not required.
15 *
16 * 2. Altered source versions must be plainly marked as such, and must not be
17 * misrepresented as being the original software.
18 *
19 * 3. This notice may not be removed or altered from any source distribution.
20 */
21 
22 #ifndef __D_MEMORY_H__
23 #define __D_MEMORY_H__
24 
25 #include "dCoreStdafx.h"
26 
27 typedef void* (*dMemAllocCallback) (size_t size);
28 typedef void (*dMemFreeCallback) (void* const ptr);
29 
30 class dMemory
31 {
32  public:
36  D_CORE_API static void* Malloc(size_t size);
37 
39  D_CORE_API static void Free(void* const ptr);
40 
42  D_CORE_API static dUnsigned64 GetMemoryUsed();
43 
57  D_CORE_API static void SetMemoryAllocators(dMemAllocCallback alloc, dMemFreeCallback free);
58 
59  private:
60  static dAtomic<dUnsigned64> m_memoryUsed;
61 };
62 
63 #endif
dAtomic< dUnsigned64 >
dMemory::Free
static D_CORE_API void Free(void *const ptr)
Destroy a memory buffer previously allocated by Malloc.
Definition: dMemory.cpp:58
dMemory
Definition: dMemory.h:31
dMemory::GetMemoryUsed
static D_CORE_API dUnsigned64 GetMemoryUsed()
Return the total memory allocated by the newton engine and tools.
Definition: dMemory.cpp:65
dMemory::Malloc
static D_CORE_API void * Malloc(size_t size)
General Memory allocation function.
Definition: dMemory.cpp:44
dMemory::SetMemoryAllocators
static D_CORE_API void SetMemoryAllocators(dMemAllocCallback alloc, dMemFreeCallback free)
Install low level system memory allocation functions.
Definition: dMemory.cpp:70