Skip to content

Commit c9d84c1

Browse files
committed
xrCore/xrString.cpp: Fixed memory allocation on 64 bit archs.
1 parent 30b64b5 commit c9d84c1

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

src/xrCore/xrstring.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
#include "FS_impl.h"
77

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

1110
#if 1
1211

@@ -153,7 +152,7 @@ str_value* str_container::dock(str_c value)
153152
// calc len
154153
u32 s_len = xr_strlen(value);
155154
u32 s_len_with_zero = (u32)s_len + 1;
156-
VERIFY(HEADER + s_len_with_zero < 4096);
155+
VERIFY(sizeof(str_value) + s_len_with_zero < 4096);
157156

158157
// setup find structure
159158
char header[sizeof(str_value)];
@@ -177,7 +176,7 @@ str_value* str_container::dock(str_c value)
177176
)
178177
{
179178

180-
result = (str_value*)Memory.mem_alloc(HEADER + s_len_with_zero
179+
result = (str_value*)Memory.mem_alloc(sizeof(str_value) + s_len_with_zero
181180
#ifdef DEBUG_MEMORY_NAME
182181
, "storage: sstring"
183182
#endif // DEBUG_MEMORY_NAME
@@ -294,7 +293,7 @@ str_value* str_container::dock(str_c value)
294293
// calc len
295294
u32 s_len = xr_strlen(value);
296295
u32 s_len_with_zero = (u32)s_len + 1;
297-
VERIFY(HEADER + s_len_with_zero < 4096);
296+
VERIFY(sizeof(str_value) + s_len_with_zero < 4096);
298297
299298
// setup find structure
300299
char header[sizeof(str_value)];
@@ -328,7 +327,7 @@ str_value* str_container::dock(str_c value)
328327
// Insert string
329328
// DUMP_PHASE;
330329
331-
result = (str_value*)Memory.mem_alloc(HEADER + s_len_with_zero
330+
result = (str_value*)Memory.mem_alloc(sizeof(str_value) + s_len_with_zero
332331
#ifdef DEBUG_MEMORY_NAME
333332
, "storage: sstring"
334333
#endif // DEBUG_MEMORY_NAME
@@ -423,7 +422,7 @@ u32 str_container::stat_economy()
423422
const int node_size = 20;
424423
for (; it != end; it++)
425424
{
426-
counter -= HEADER;
425+
counter -= sizeof(str_value);
427426
counter -= node_size;
428427
counter += int((int((*it)->dwReference) - 1)*int((*it)->dwLength + 1));
429428
}

0 commit comments

Comments
 (0)