Skip to content

Commit

Permalink
Replace memory functions.
Browse files Browse the repository at this point in the history
  • Loading branch information
intorr committed Feb 27, 2018
1 parent 0c93fa0 commit 5a5f18d
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 26 deletions.
20 changes: 10 additions & 10 deletions src/Layers/xrRender/DetailManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,18 +96,18 @@ CDetailManager::CDetailManager() : xrc("detail manager")
dm_cache_size = dm_current_cache_size;
dm_fade = dm_current_fade;
ps_r__Detail_density = ps_current_detail_density;
cache_level1 = (CacheSlot1**)Memory.mem_alloc(dm_cache1_line * sizeof(CacheSlot1*));
cache_level1 = (CacheSlot1**)xr_malloc(dm_cache1_line * sizeof(CacheSlot1*));
for (u32 i = 0; i < dm_cache1_line; ++i)
{
cache_level1[i] = (CacheSlot1*)Memory.mem_alloc(dm_cache1_line * sizeof(CacheSlot1));
cache_level1[i] = (CacheSlot1*)xr_malloc(dm_cache1_line * sizeof(CacheSlot1));
for (u32 j = 0; j < dm_cache1_line; ++j)
new(&cache_level1[i][j]) CacheSlot1();
}
cache = (Slot***)Memory.mem_alloc(dm_cache_line * sizeof(Slot**));
cache = (Slot***)xr_malloc(dm_cache_line * sizeof(Slot**));
for (u32 i = 0; i < dm_cache_line; ++i)
cache[i] = (Slot**)Memory.mem_alloc(dm_cache_line * sizeof(Slot*));
cache[i] = (Slot**)xr_malloc(dm_cache_line * sizeof(Slot*));

cache_pool = (Slot *)Memory.mem_alloc(dm_cache_size * sizeof(Slot));
cache_pool = (Slot *)xr_malloc(dm_cache_size * sizeof(Slot));

for (u32 i = 0; i < dm_cache_size; ++i)
new(&cache_pool[i]) Slot();
Expand All @@ -124,19 +124,19 @@ CDetailManager::~CDetailManager()
#ifdef DETAIL_RADIUS
for (u32 i = 0; i < dm_cache_size; ++i)
cache_pool[i].~Slot();
Memory.mem_free(cache_pool);
xr_free(cache_pool);

for (u32 i = 0; i < dm_cache_line; ++i)
Memory.mem_free(cache[i]);
Memory.mem_free(cache);
xr_free(cache[i]);
xr_free(cache);

for (u32 i = 0; i < dm_cache1_line; ++i)
{
for (u32 j = 0; j < dm_cache1_line; ++j)
cache_level1[i][j].~CacheSlot1();
Memory.mem_free(cache_level1[i]);
xr_free(cache_level1[i]);
}
Memory.mem_free(cache_level1);
xr_free(cache_level1);
#endif
}
/*
Expand Down
2 changes: 1 addition & 1 deletion src/utils/xrLC/nv_library/NvTriStripObjects.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class NvEdgeInfo
{
if (--m_refCount == 0)
{
Memory.mem_free(this);
delete this;
}
}

Expand Down
12 changes: 6 additions & 6 deletions src/utils/xrLC_Light/net_stream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ void INetBlockReader::create_block(u32 size)
/*
if( !_buffer )
{
_buffer = (u8*) Memory.mem_alloc ( size
_buffer = (u8*) xr_malloc ( size
#ifdef DEBUG_MEMORY_NAME
, "INetBlockReader - storage"
#endif // DEBUG_MEMORY_NAME
Expand All @@ -64,7 +64,7 @@ void INetBlockReader::create_block(u32 size)
}
if( _block_size < size )
{
_buffer = (u8*)Memory.mem_realloc (_buffer,size
_buffer = (u8*)xr_realloc (_buffer,size
#ifdef DEBUG_MEMORY_NAME
, "CMemoryWriter - storage"
#endif // DEBUG_MEMORY_NAME
Expand All @@ -80,7 +80,7 @@ INetBlockReader::~INetBlockReader()
{
R_ASSERT(!mem_reader.allocated() || mem_reader.count() == 0);
mem_reader.free_buff();
// Memory.mem_free( _buffer );
// xr_free( _buffer );
}
/*
IC void w_string(const char *p) { w(p,(u32)xr_strlen(p));w_u8(13);w_u8(10); }
Expand Down Expand Up @@ -235,7 +235,7 @@ INetFileBuffWriter::INetFileBuffWriter(LPCSTR _file_name, u32 block_size, bool _

INetFileBuffWriter::~INetFileBuffWriter() { xr_delete(mem_writter); }
/*
data = (BYTE*) Memory.mem_realloc (data,mem_size
data = (BYTE*) xr_realloc (data,mem_size
#ifdef DEBUG_MEMORY_NAME
, "CMemoryWriter - storage"
#endif // DEBUG_MEMORY_NAME
Expand All @@ -252,7 +252,7 @@ CReadMemoryBlock::CReadMemoryBlock(const u32 buff_size_, u8* buffer)
: buf_size(buff_size_), file_size(0), position(0), _buffer(buffer)
{
/*
data = (u8*) Memory.mem_alloc (file_size_
data = (u8*) xr_malloc (file_size_
#ifdef DEBUG_MEMORY_NAME
, "CReadMemoryBlock - storage"
#endif // DEBUG_MEMORY_NAME
Expand All @@ -263,7 +263,7 @@ CReadMemoryBlock::CReadMemoryBlock(const u32 buff_size_, u8* buffer)

CReadMemoryBlock::~CReadMemoryBlock()
{
// Memory.mem_free( data );
// xr_free( data );
}

#include "xrCore/FS_impl.h"
Expand Down
2 changes: 1 addition & 1 deletion src/utils/xrLC_Light/net_task_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ void net_task_manager::create_global_data_write(LPCSTR save_path)

// g_net_data = new CVirtualFileRW(global_data_file_name);

// dbg_buf = Memory.mem_alloc( 560000000, "dbg_buf" );
// dbg_buf = xr_malloc( 560000000, "dbg_buf" );
////////////////
/*{
string_path blfile_name;
Expand Down
6 changes: 3 additions & 3 deletions src/xrCore/FS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ bool file_handle_internal(LPCSTR file_name, u32& size, int& file_handle)

void* FileDownload(LPCSTR file_name, const int& file_handle, u32& file_size)
{
void* buffer = Memory.mem_alloc(file_size);
void* buffer = xr_malloc(file_size);

int r_bytes = _read(file_handle, buffer, file_size);
R_ASSERT3(
Expand Down Expand Up @@ -199,9 +199,9 @@ void CMemoryWriter::w(const void* ptr, u32 count)
while (mem_size <= (position + count))
mem_size *= 2;
if (0 == data)
data = (BYTE*)Memory.mem_alloc(mem_size);
data = (BYTE*)xr_malloc(mem_size);
else
data = (BYTE*)Memory.mem_realloc(data, mem_size);
data = (BYTE*)xr_realloc(data, mem_size);
}
CopyMemory(data + position, ptr, count);
position += count;
Expand Down
4 changes: 2 additions & 2 deletions src/xrCore/xrstring.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ str_value* str_container::dock(pcstr value)
#endif // DEBUG
)
{
result = (str_value*)Memory.mem_alloc(sizeof(str_value) + s_len_with_zero);
result = (str_value*)xr_malloc(sizeof(str_value) + s_len_with_zero);

#ifdef DEBUG
static int num_leaked_string = 0;
Expand Down Expand Up @@ -325,7 +325,7 @@ str_value* str_container::dock(str_c value)
{
// Insert string
result = (str_value*)Memory.mem_alloc(sizeof(str_value) + s_len_with_zero
result = (str_value*)xr_malloc(sizeof(str_value) + s_len_with_zero
#ifdef DEBUG_MEMORY_NAME
,
"storage: sstring"
Expand Down
6 changes: 3 additions & 3 deletions src/xrScriptEngine/script_engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ static void* lua_alloc(void* ud, void* ptr, size_t osize, size_t nsize)
xr_free(ptr);
return nullptr;
}
return Memory.mem_realloc(ptr, nsize);
return xr_realloc(ptr, nsize);
}

static void* __cdecl luabind_allocator(void* context, const void* pointer, size_t const size)
Expand All @@ -63,10 +63,10 @@ static void* __cdecl luabind_allocator(void* context, const void* pointer, size_
}
if (!pointer)
{
return Memory.mem_alloc(size);
return xr_malloc(size);
}
void* non_const_pointer = const_cast<LPVOID>(pointer);
return Memory.mem_realloc(non_const_pointer, size);
return xr_realloc(non_const_pointer, size);
}

namespace
Expand Down

0 comments on commit 5a5f18d

Please sign in to comment.