Skip to content

Commit

Permalink
xrCore/xrString.cpp: Fixed memory allocation on 64 bit archs.
Browse files Browse the repository at this point in the history
  • Loading branch information
Kaffeine committed Nov 16, 2015
1 parent 30b64b5 commit c9d84c1
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/xrCore/xrstring.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
#include "FS_impl.h"

XRCORE_API extern str_container* g_pStringContainer = NULL;
#define HEADER 16 // ref + len + crc + next

#if 1

Expand Down Expand Up @@ -153,7 +152,7 @@ str_value* str_container::dock(str_c value)
// calc len
u32 s_len = xr_strlen(value);
u32 s_len_with_zero = (u32)s_len + 1;
VERIFY(HEADER + s_len_with_zero < 4096);
VERIFY(sizeof(str_value) + s_len_with_zero < 4096);

// setup find structure
char header[sizeof(str_value)];
Expand All @@ -177,7 +176,7 @@ str_value* str_container::dock(str_c value)
)
{

result = (str_value*)Memory.mem_alloc(HEADER + s_len_with_zero
result = (str_value*)Memory.mem_alloc(sizeof(str_value) + s_len_with_zero
#ifdef DEBUG_MEMORY_NAME
, "storage: sstring"
#endif // DEBUG_MEMORY_NAME
Expand Down Expand Up @@ -294,7 +293,7 @@ str_value* str_container::dock(str_c value)
// calc len
u32 s_len = xr_strlen(value);
u32 s_len_with_zero = (u32)s_len + 1;
VERIFY(HEADER + s_len_with_zero < 4096);
VERIFY(sizeof(str_value) + s_len_with_zero < 4096);
// setup find structure
char header[sizeof(str_value)];
Expand Down Expand Up @@ -328,7 +327,7 @@ str_value* str_container::dock(str_c value)
// Insert string
// DUMP_PHASE;
result = (str_value*)Memory.mem_alloc(HEADER + s_len_with_zero
result = (str_value*)Memory.mem_alloc(sizeof(str_value) + s_len_with_zero
#ifdef DEBUG_MEMORY_NAME
, "storage: sstring"
#endif // DEBUG_MEMORY_NAME
Expand Down Expand Up @@ -423,7 +422,7 @@ u32 str_container::stat_economy()
const int node_size = 20;
for (; it != end; it++)
{
counter -= HEADER;
counter -= sizeof(str_value);
counter -= node_size;
counter += int((int((*it)->dwReference) - 1)*int((*it)->dwLength + 1));
}
Expand Down

0 comments on commit c9d84c1

Please sign in to comment.