summaryrefslogtreecommitdiffstats
path: root/src/core/templates.h
diff options
context:
space:
mode:
authoraap <aap@papnet.eu>2020-11-28 18:52:44 +0100
committerGitHub <noreply@github.com>2020-11-28 18:52:44 +0100
commitc57fee38caed4cc770aa8e57b74672ca85aa0fa3 (patch)
treed9b0a02ad6c0d81fc78b9c8f0bbb018189d92d39 /src/core/templates.h
parentMake texture conversion work a bit faster (diff)
parentmoved some stuff to MemoryMgr (diff)
downloadre3-c57fee38caed4cc770aa8e57b74672ca85aa0fa3.tar
re3-c57fee38caed4cc770aa8e57b74672ca85aa0fa3.tar.gz
re3-c57fee38caed4cc770aa8e57b74672ca85aa0fa3.tar.bz2
re3-c57fee38caed4cc770aa8e57b74672ca85aa0fa3.tar.lz
re3-c57fee38caed4cc770aa8e57b74672ca85aa0fa3.tar.xz
re3-c57fee38caed4cc770aa8e57b74672ca85aa0fa3.tar.zst
re3-c57fee38caed4cc770aa8e57b74672ca85aa0fa3.zip
Diffstat (limited to 'src/core/templates.h')
-rw-r--r--src/core/templates.h16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/core/templates.h b/src/core/templates.h
index 4f7b8490..86239664 100644
--- a/src/core/templates.h
+++ b/src/core/templates.h
@@ -46,8 +46,8 @@ class CPool
public:
CPool(int size){
// TODO: use new here
- m_entries = (U*)malloc(sizeof(U)*size);
- m_flags = (Flags*)malloc(sizeof(Flags)*size);
+ m_entries = (U*)new uint8[sizeof(U)*size];
+ m_flags = (Flags*)new uint8[sizeof(Flags)*size];
m_size = size;
m_allocPtr = 0;
for(int i = 0; i < size; i++){
@@ -61,8 +61,8 @@ public:
}
void Flush() {
if (m_size > 0) {
- free(m_entries);
- free(m_flags);
+ delete[] (uint8*)m_entries;
+ delete[] (uint8*)m_flags;
m_entries = nil;
m_flags = nil;
m_size = 0;
@@ -141,8 +141,8 @@ public:
}
bool IsFreeSlot(int i) { return !!m_flags[i].free; }
void ClearStorage(uint8 *&flags, U *&entries){
- free(flags);
- free(entries);
+ delete[] (uint8*)flags;
+ delete[] (uint8*)entries;
flags = nil;
entries = nil;
}
@@ -156,8 +156,8 @@ public:
debug("CopyBack:%d (/%d)\n", GetNoOfUsedSpaces(), m_size); /* Assumed inlining */
}
void Store(uint8 *&flags, U *&entries){
- flags = (uint8*)malloc(sizeof(uint8)*m_size);
- entries = (U*)malloc(sizeof(U)*m_size);
+ flags = (uint8*)new uint8[sizeof(uint8)*m_size];
+ entries = (U*)new uint8[sizeof(U)*m_size];
memcpy(flags, m_flags, sizeof(uint8)*m_size);
memcpy(entries, m_entries, sizeof(U)*m_size);
debug("Stored:%d (/%d)\n", GetNoOfUsedSpaces(), m_size); /* Assumed inlining */