Skip to content

Commit 508755e

Browse files
committed
Remove DEBUG_MEMORY_NAME and xrMemory_subst_borland.*
1 parent 842ba40 commit 508755e

13 files changed

+9
-156
lines changed

src/Layers/xrRender/DetailManager.cpp

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -96,38 +96,18 @@ CDetailManager::CDetailManager() : xrc("detail manager")
9696
dm_cache_size = dm_current_cache_size;
9797
dm_fade = dm_current_fade;
9898
ps_r__Detail_density = ps_current_detail_density;
99-
#ifdef DEBUG_MEMORY_NAME
100-
cache_level1 = (CacheSlot1**)Memory.mem_alloc(dm_cache1_line * sizeof(CacheSlot1*), "CDetailManager::cache_level1");
101-
#else
10299
cache_level1 = (CacheSlot1**)Memory.mem_alloc(dm_cache1_line * sizeof(CacheSlot1*));
103-
#endif
104100
for (u32 i = 0; i < dm_cache1_line; ++i)
105101
{
106-
#ifdef DEBUG_MEMORY_NAME
107-
cache_level1[i] = (CacheSlot1*)Memory.mem_alloc(dm_cache1_line * sizeof(CacheSlot1), "CDetailManager::cache_level1 " + i);
108-
#else
109102
cache_level1[i] = (CacheSlot1*)Memory.mem_alloc(dm_cache1_line * sizeof(CacheSlot1));
110-
#endif
111103
for (u32 j = 0; j < dm_cache1_line; ++j)
112104
new(&cache_level1[i][j]) CacheSlot1();
113105
}
114-
#ifdef DEBUG_MEMORY_NAME
115-
cache = (Slot***)Memory.mem_alloc(dm_cache_line * sizeof(Slot**), "CDetailManager::cache");
116-
#else
117106
cache = (Slot***)Memory.mem_alloc(dm_cache_line * sizeof(Slot**));
118-
#endif
119107
for (u32 i = 0; i < dm_cache_line; ++i)
120-
#ifdef DEBUG_MEMORY_NAME
121-
cache[i] = (Slot**)Memory.mem_alloc(dm_cache_line * sizeof(Slot*), "CDetailManager::cache " + i);
122-
#else
123108
cache[i] = (Slot**)Memory.mem_alloc(dm_cache_line * sizeof(Slot*));
124-
#endif
125109

126-
#ifdef DEBUG_MEMORY_NAME
127-
cache_pool = (Slot *)Memory.mem_alloc(dm_cache_size * sizeof(Slot), "CDetailManager::cache_pool");
128-
#else
129110
cache_pool = (Slot *)Memory.mem_alloc(dm_cache_size * sizeof(Slot));
130-
#endif
131111

132112
for (u32 i = 0; i < dm_cache_size; ++i)
133113
new(&cache_pool[i]) Slot();

src/xrCore/FS.cpp

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -122,12 +122,7 @@ bool file_handle_internal(LPCSTR file_name, u32& size, int& file_handle)
122122

123123
void* FileDownload(LPCSTR file_name, const int& file_handle, u32& file_size)
124124
{
125-
void* buffer = Memory.mem_alloc(file_size
126-
#ifdef DEBUG_MEMORY_NAME
127-
,
128-
"FILE in memory"
129-
#endif // DEBUG_MEMORY_NAME
130-
);
125+
void* buffer = Memory.mem_alloc(file_size);
131126

132127
int r_bytes = _read(file_handle, buffer, file_size);
133128
R_ASSERT3(
@@ -204,19 +199,9 @@ void CMemoryWriter::w(const void* ptr, u32 count)
204199
while (mem_size <= (position + count))
205200
mem_size *= 2;
206201
if (0 == data)
207-
data = (BYTE*)Memory.mem_alloc(mem_size
208-
#ifdef DEBUG_MEMORY_NAME
209-
,
210-
"CMemoryWriter - storage"
211-
#endif // DEBUG_MEMORY_NAME
212-
);
202+
data = (BYTE*)Memory.mem_alloc(mem_size);
213203
else
214-
data = (BYTE*)Memory.mem_realloc(data, mem_size
215-
#ifdef DEBUG_MEMORY_NAME
216-
,
217-
"CMemoryWriter - storage"
218-
#endif // DEBUG_MEMORY_NAME
219-
);
204+
data = (BYTE*)Memory.mem_realloc(data, mem_size);
220205
}
221206
CopyMemory(data + position, ptr, count);
222207
position += count;

src/xrCore/xrCore.vcxproj

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,6 @@
245245
<ClCompile Include="xrMemory_align.cpp" />
246246
<ClCompile Include="xrMemory_debug.cpp" />
247247
<ClCompile Include="xrMemory_POOL.cpp" />
248-
<ClCompile Include="xrMemory_subst_borland.cpp" />
249248
<ClCompile Include="xrMemory_subst_msvc.cpp" />
250249
<ClCompile Include="xrsharedmem.cpp" />
251250
<ClCompile Include="xrstring.cpp" />
@@ -357,7 +356,6 @@
357356
<ClInclude Include="xrMemory.h" />
358357
<ClInclude Include="xrMemory_align.h" />
359358
<ClInclude Include="xrMemory_POOL.h" />
360-
<ClInclude Include="xrMemory_subst_borland.h" />
361359
<ClInclude Include="xrMemory_subst_msvc.h" />
362360
<ClInclude Include="xrPool.h" />
363361
<ClInclude Include="xrsharedmem.h" />

src/xrCore/xrCore.vcxproj.filters

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -213,9 +213,6 @@
213213
<ClCompile Include="xrMemory_POOL.cpp">
214214
<Filter>Memory\Memory manager</Filter>
215215
</ClCompile>
216-
<ClCompile Include="xrMemory_subst_borland.cpp">
217-
<Filter>Memory\Memory manager</Filter>
218-
</ClCompile>
219216
<ClCompile Include="xrMemory_subst_msvc.cpp">
220217
<Filter>Memory\Memory manager</Filter>
221218
</ClCompile>
@@ -512,9 +509,6 @@
512509
<ClInclude Include="xrMemory_align.h">
513510
<Filter>Memory\Memory manager</Filter>
514511
</ClInclude>
515-
<ClInclude Include="xrMemory_subst_borland.h">
516-
<Filter>Memory\Memory manager</Filter>
517-
</ClInclude>
518512
<ClInclude Include="xrMemory_subst_msvc.h">
519513
<Filter>Memory\Memory manager</Filter>
520514
</ClInclude>

src/xrCore/xrMemory.cpp

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -260,12 +260,7 @@ char* xr_strdup(const char* string)
260260
{
261261
VERIFY(string);
262262
u32 len = u32(xr_strlen(string)) + 1;
263-
char* memory = (char*)Memory.mem_alloc(len
264-
#ifdef DEBUG_MEMORY_NAME
265-
,
266-
"strdup"
267-
#endif // DEBUG_MEMORY_NAME
268-
);
263+
char* memory = (char*)Memory.mem_alloc(len);
269264
CopyMemory(memory, string, len);
270265
return memory;
271266
}
@@ -279,10 +274,5 @@ XRCORE_API BOOL is_stack_ptr(void* _ptr)
279274
return (difference < (512 * 1024));
280275
}
281276

282-
#ifdef DEBUG_MEMORY_NAME
283-
XRCORE_API void* xr_malloc(size_t size) { return Memory.mem_alloc(size, "xr_malloc"); }
284-
XRCORE_API void* xr_realloc(void* P, size_t size) { return Memory.mem_realloc(P, size, "xr_realloc"); }
285-
#else
286277
XRCORE_API void* xr_malloc(size_t size) { return Memory.mem_alloc(size); }
287278
XRCORE_API void* xr_realloc(void* P, size_t size) { return Memory.mem_realloc(P, size); }
288-
#endif

src/xrCore/xrMemory.h

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,9 @@ class XRCORE_API xrMemory
7272
u32 mem_counter_get() { return stat_counter; }
7373
#ifdef DEBUG_MEMORY_NAME
7474
void mem_statistic(const char* fn);
75-
void* mem_alloc(size_t size, const char* _name);
76-
void* mem_realloc(void* p, size_t size, const char* _name);
77-
#else // DEBUG_MEMORY_NAME
75+
#endif // DEBUG_MEMORY_NAME
7876
void* mem_alloc(size_t size);
7977
void* mem_realloc(void* p, size_t size);
80-
#endif // DEBUG_MEMORY_NAME
8178
void mem_free(void* p);
8279
};
8380

@@ -98,18 +95,10 @@ extern XRCORE_API xrMemory Memory;
9895
#endif
9996

10097
// generic "C"-like allocations/deallocations
101-
#ifdef DEBUG_MEMORY_NAME
102-
#include "typeinfo.h"
103-
template <class T>
104-
IC T* xr_alloc(size_t count)
105-
{ return (T*)Memory.mem_alloc(count*sizeof(T), typeid(T).name()); }
106-
107-
#else
10898
template <class T>
10999
IC T* xr_alloc(size_t count)
110100
{ return (T*)Memory.mem_alloc(count * sizeof(T)); }
111101

112-
#endif
113102

114103
template <class T>
115104
IC void xr_free(T*& P) throw()

src/xrCore/xrMemory_subst_borland.cpp

Lines changed: 0 additions & 24 deletions
This file was deleted.

src/xrCore/xrMemory_subst_borland.h

Lines changed: 0 additions & 10 deletions
This file was deleted.

src/xrCore/xrMemory_subst_msvc.cpp

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
#include "stdafx.h"
22
#include "xrMemory_align.h"
33

4-
#ifndef __BORLANDC__
5-
64
#ifndef DEBUG_MEMORY_MANAGER
75
#define debug_mode 0
86
#endif
@@ -14,6 +12,8 @@ extern void save_stack_trace();
1412

1513
MEMPOOL mem_pools[mem_pools_count];
1614

15+
constexpr pcstr _name = "_noname_";
16+
1717
// MSVC
1818
ICF u8* acc_header(void* P) { return (u8*)P - 1; }
1919
ICF u32 get_header(void* P) { return (u32)*acc_header(P); }
@@ -27,11 +27,7 @@ ICF u32 get_pool(size_t size)
2727

2828
static bool g_use_pure_alloc = false;
2929

30-
#ifdef DEBUG_MEMORY_NAME
31-
void* xrMemory::mem_alloc(size_t size, const char* _name)
32-
#else
3330
void* xrMemory::mem_alloc(size_t size)
34-
#endif
3531
{
3632
if (!size)
3733
size = 1; // While allocationg 0 bytes is valid, let's mimic the old code for now.
@@ -138,11 +134,7 @@ void xrMemory::mem_free(void* P)
138134

139135
extern BOOL g_bDbgFillMemory;
140136

141-
#ifdef DEBUG_MEMORY_NAME
142-
void* xrMemory::mem_realloc(void* P, size_t size, const char* _name)
143-
#else
144137
void* xrMemory::mem_realloc(void* P, size_t size)
145-
#endif
146138
{
147139
stat_calls++;
148140
if (g_use_pure_alloc)
@@ -156,11 +148,7 @@ void* xrMemory::mem_realloc(void* P, size_t size)
156148
}
157149
if (!P)
158150
{
159-
#ifdef DEBUG_MEMORY_NAME
160-
return mem_alloc(size, _name);
161-
#else
162151
return mem_alloc(size);
163-
#endif
164152
}
165153
#ifdef DEBUG_MEMORY_MANAGER
166154
if (g_globalCheckAddr == P)
@@ -212,11 +200,7 @@ void* xrMemory::mem_realloc(void* P, size_t size)
212200
u32 s_current = mem_pools[p_current].get_element();
213201
u32 s_dest = (u32)size;
214202
void* p_old = P;
215-
#ifdef DEBUG_MEMORY_NAME
216-
void* p_new = mem_alloc(size, _name);
217-
#else
218203
void* p_new = mem_alloc(size);
219-
#endif
220204
// Igor: Reserve 1 byte for xrMemory header
221205
// Don't bother in this case?
222206
memcpy(p_new, p_old, std::min(s_current - 1, s_dest));
@@ -227,11 +211,7 @@ void* xrMemory::mem_realloc(void* P, size_t size)
227211
{
228212
// relocate into another mmgr(pooled) from real
229213
void* p_old = P;
230-
#ifdef DEBUG_MEMORY_NAME
231-
void* p_new = mem_alloc(size, _name);
232-
#else
233214
void* p_new = mem_alloc(size);
234-
#endif
235215
memcpy(p_new, p_old, (u32)size);
236216
mem_free(p_old);
237217
_ptr = p_new;
@@ -244,5 +224,3 @@ void* xrMemory::mem_realloc(void* P, size_t size)
244224
#endif
245225
return _ptr;
246226
}
247-
248-
#endif // __BORLANDC__

src/xrCore/xrsharedmem.cpp

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,7 @@ smem_value* smem_container::dock(u32 dwCRC, u32 dwLength, void* ptr)
6161
// if not found - create new entry
6262
if (0 == result)
6363
{
64-
result = (smem_value*)Memory.mem_alloc(4 * sizeof(u32) + dwLength
65-
#ifdef DEBUG_MEMORY_NAME
66-
,
67-
"storage: smem"
68-
#endif // DEBUG_MEMORY_NAME
69-
);
64+
result = (smem_value*)Memory.mem_alloc(4 * sizeof(u32) + dwLength);
7065
result->dwReference = 0;
7166
result->dwCRC = dwCRC;
7267
result->dwLength = dwLength;

src/xrCore/xrstring.cpp

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -183,12 +183,7 @@ str_value* str_container::dock(pcstr value)
183183
#endif // DEBUG
184184
)
185185
{
186-
result = (str_value*)Memory.mem_alloc(sizeof(str_value) + s_len_with_zero
187-
#ifdef DEBUG_MEMORY_NAME
188-
,
189-
"storage: sstring"
190-
#endif // DEBUG_MEMORY_NAME
191-
);
186+
result = (str_value*)Memory.mem_alloc(sizeof(str_value) + s_len_with_zero);
192187

193188
#ifdef DEBUG
194189
static int num_leaked_string = 0;

src/xrMisc/xrMisc_xrMemory.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,8 @@
88
#endif
99

1010
#ifndef NO_XRNEW
11-
#ifdef DEBUG_MEMORY_NAME
12-
void* operator new(size_t size) { return Memory.mem_alloc(size, "C++ NEW"); }
13-
void* operator new[](size_t size) { return Memory.mem_alloc(size, "C++ NEW[]"); }
14-
#else
1511
void* operator new(size_t size) { return Memory.mem_alloc(size); }
1612
void* operator new[](size_t size) { return Memory.mem_alloc(size); }
17-
#endif
1813

1914
void operator delete(void* p) throw() { Memory.mem_free(p); }
2015
void operator delete[](void* p) throw() { Memory.mem_free(p); }

src/xrScriptEngine/script_engine.cpp

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,7 @@ static void* lua_alloc(void* ud, void* ptr, size_t osize, size_t nsize)
5050
xr_free(ptr);
5151
return nullptr;
5252
}
53-
#ifdef DEBUG_MEMORY_NAME
54-
return Memory.mem_realloc(ptr, nsize, "LUA");
55-
#else
5653
return Memory.mem_realloc(ptr, nsize);
57-
#endif
5854
}
5955

6056
static void* __cdecl luabind_allocator(void* context, const void* pointer, size_t const size)
@@ -67,18 +63,10 @@ static void* __cdecl luabind_allocator(void* context, const void* pointer, size_
6763
}
6864
if (!pointer)
6965
{
70-
#ifdef DEBUG_MEMORY_NAME
71-
return Memory.mem_alloc(size, "luabind");
72-
#else
7366
return Memory.mem_alloc(size);
74-
#endif
7567
}
7668
void* non_const_pointer = const_cast<LPVOID>(pointer);
77-
#ifdef DEBUG_MEMORY_NAME
78-
return Memory.mem_realloc(non_const_pointer, size, "luabind");
79-
#else
8069
return Memory.mem_realloc(non_const_pointer, size);
81-
#endif
8270
}
8371

8472
namespace

0 commit comments

Comments
 (0)