Skip to content

Commit

Permalink
Linux: fix some of Valgrind errors
Browse files Browse the repository at this point in the history
  • Loading branch information
eagleivg committed Nov 6, 2018
1 parent fbe4a03 commit a38ba88
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 15 deletions.
24 changes: 12 additions & 12 deletions src/xrCore/NET_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -302,71 +302,71 @@ float NET_Packet::r_float()

u64 NET_Packet::r_u64()
{
u64 A;
u64 A = 0;
r_u64(A);
return (A);
} // qword (8b)

s64 NET_Packet::r_s64()
{
s64 A;
s64 A = 0;
r_s64(A);
return (A);
} // qword (8b)

u32 NET_Packet::r_u32()
{
u32 A;
u32 A = 0;
r_u32(A);
return (A);
} // dword (4b)

s32 NET_Packet::r_s32()
{
s32 A;
s32 A = 0;
r_s32(A);
return (A);
} // dword (4b)

u16 NET_Packet::r_u16()
{
u16 A;
u16 A = 0;
r_u16(A);
return (A);
} // word (2b)

s16 NET_Packet::r_s16()
{
s16 A;
s16 A = 0;
r_s16(A);
return (A);
} // word (2b)

u8 NET_Packet::r_u8()
{
u8 A;
u8 A = 0;
r_u8(A);
return (A);
} // byte (1b)

s8 NET_Packet::r_s8()
{
s8 A;
s8 A = 0;
r_s8(A);
return (A);
}

void NET_Packet::r_float_q16(float& A, float min, float max)
{
u16 val;
u16 val = 0;
r_u16(val);
A = (float(val) * (max - min)) / 65535.f + min; // floating-point-error possible
VERIFY((A >= min - EPS_S) && (A <= max + EPS_S));
}

void NET_Packet::r_float_q8(float& A, float min, float max)
{
u8 val;
u8 val = 0;
r_u8(val);
A = (float(val) / 255.0001f) * (max - min) + min; // floating-point-error possible
VERIFY((A >= min) && (A <= max));
Expand All @@ -376,7 +376,7 @@ void NET_Packet::r_angle16(float& A) { r_float_q16(A, 0, PI_MUL_2); }
void NET_Packet::r_angle8(float& A) { r_float_q8(A, 0, PI_MUL_2); }
void NET_Packet::r_dir(Fvector& A)
{
u16 t;
u16 t = 0;
r_u16(t);
pvDecompress(A, t);
}
Expand Down Expand Up @@ -429,7 +429,7 @@ void NET_Packet::r_stringZ(shared_str& dest)
}
else
{
string4096 buff;
string4096 buff = { 0 };
inistream->r_string(buff, sizeof(buff));
dest = buff;
}
Expand Down
2 changes: 1 addition & 1 deletion src/xrCore/net_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ class XRCORE_API NET_Packet
B.count = size;
}

NET_Buffer B;
NET_Buffer B = {{0}, 0};
u32 r_pos;
u32 timeReceive;
bool w_allow;
Expand Down
5 changes: 3 additions & 2 deletions src/xrGame/MainMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,8 @@ void CMainMenu::ReadTextureInfo()
* Multi-threaded ~40 ms
* Just a bit of speedup
*/
tbb::parallel_for_each(files, [](const FS_File& file)
// tbb::parallel_for_each(files, [](const FS_File& file) // Cause memory corruption (detected by Valgrind)
std::for_each(files.begin(), files.end(), [](const FS_File& file)
{
string_path path, name;
_splitpath(file.name.c_str(), nullptr, path, name, nullptr);
Expand Down Expand Up @@ -896,7 +897,7 @@ LPCSTR CMainMenu::GetPlayerName()

LPCSTR CMainMenu::GetCDKeyFromRegistry()
{
string512 key;
string512 key = { 0 };
GetCDKey_FromRegistry(key);
m_cdkey._set(key);
return m_cdkey.c_str();
Expand Down

0 comments on commit a38ba88

Please sign in to comment.