Update README.md
[nemesis.git] / Platform / Memory.cpp
1 /*
2  Copyright (c) 2008 TrueCrypt Developers Association. All rights reserved.
3
4  Governed by the TrueCrypt License 3.0 the full text of which is contained in
5  the file License.txt included in TrueCrypt binary and source code distribution
6  packages.
7 */
8
9 #include "Common/Tcdefs.h"
10 #include "Memory.h"
11 #include "Exception.h"
12
13 namespace TrueCrypt
14 {
15         void *Memory::Allocate (std::size_t size)
16         {
17                 if (size < 1)
18                         throw ParameterIncorrect (SRC_POS);
19
20                 void *bufPtr = malloc (size);
21                 if (!bufPtr)
22                         throw bad_alloc();
23
24                 return bufPtr;
25         }
26
27         int Memory::Compare (const void *memory1, size_t size1, const void *memory2, size_t size2)
28         {
29                 if (size1 > size2)
30                         return 1;
31                 else if (size1 < size2)
32                         return -1;
33                 
34                 return memcmp (memory1, memory2, size1);
35         }
36
37         void Memory::Copy (void *memoryDestination, const void *memorySource, size_t size)
38         {
39                 assert (memoryDestination != nullptr && memorySource != nullptr);
40                 memcpy (memoryDestination, memorySource, size);
41         }
42
43         void Memory::Erase (void *memory, size_t size)
44         {
45                 burn (memory, size);
46         }
47
48         void Memory::Zero (void *memory, size_t size)
49         {
50                 memset (memory, 0, size);
51         }
52
53         void Memory::Free (void *memory)
54         {
55                 assert (memory != nullptr);
56                 free (memory);
57         }
58 }
This page took 0.017487 seconds and 3 git commands to generate. Download a nemesis OSX (sierra+high sierra, tested/working) binary, with fuse-ext3 via e2fsprogs, at this link. application and installer are signed by screwjack, llc. must install fuse with macFUSE layer first.