Get rid of memsets
parent
0c9e745213
commit
bdeeaf690b
|
@ -93,8 +93,8 @@ struct ApplicationPrivate
|
|||
|
||||
ApplicationPrivate()
|
||||
{
|
||||
memset(¤tEvent, 0, sizeof(SDL_Event));
|
||||
memset(&lastMouseMotionEvent, 0, sizeof(SDL_Event));
|
||||
SDL_memset(¤tEvent, 0, sizeof(SDL_Event));
|
||||
SDL_memset(&lastMouseMotionEvent, 0, sizeof(SDL_Event));
|
||||
surface = nullptr;
|
||||
joystick = nullptr;
|
||||
joystickTimer = 0;
|
||||
|
|
|
@ -94,8 +94,15 @@ inline bool ReadBinaryBool(std::istream &istr)
|
|||
*/
|
||||
inline void WriteBinaryFloat(float value, std::ostream &ostr)
|
||||
{
|
||||
union { float fValue; unsigned int iValue; } u;
|
||||
memset(&u, 0, sizeof(u));
|
||||
union FloatCast
|
||||
{
|
||||
float fValue;
|
||||
unsigned int iValue;
|
||||
};
|
||||
FloatCast u;
|
||||
u.fValue = 0.0f;
|
||||
u.iValue = 0;
|
||||
|
||||
u.fValue = value;
|
||||
IOUtils::WriteBinary<4, unsigned int>(u.iValue, ostr);
|
||||
}
|
||||
|
@ -107,8 +114,15 @@ inline void WriteBinaryFloat(float value, std::ostream &ostr)
|
|||
*/
|
||||
inline float ReadBinaryFloat(std::istream &istr)
|
||||
{
|
||||
union { float fValue; unsigned int iValue; } u;
|
||||
memset(&u, 0, sizeof(u));
|
||||
union FloatCast
|
||||
{
|
||||
float fValue;
|
||||
unsigned int iValue;
|
||||
};
|
||||
FloatCast u;
|
||||
u.fValue = 0.0f;
|
||||
u.iValue = 0;
|
||||
|
||||
u.iValue = IOUtils::ReadBinary<4, unsigned int>(istr);
|
||||
return u.fValue;
|
||||
}
|
||||
|
|
|
@ -317,7 +317,7 @@ int CParticle::CreateParticle(Math::Vector pos, Math::Vector speed, Math::Point
|
|||
|
||||
if (! m_particle[i].used)
|
||||
{
|
||||
memset(&m_particle[i], 0, sizeof(Particle));
|
||||
m_particle[i] = Particle();
|
||||
m_particle[i].used = true;
|
||||
m_particle[i].ray = false;
|
||||
m_particle[i].uniqueStamp = m_uniqueStamp++;
|
||||
|
@ -387,7 +387,7 @@ int CParticle::CreateFrag(Math::Vector pos, Math::Vector speed,
|
|||
|
||||
if (!m_particle[i].used)
|
||||
{
|
||||
memset(&m_particle[i], 0, sizeof(Particle));
|
||||
m_particle[i] = Particle();
|
||||
m_particle[i].used = true;
|
||||
m_particle[i].ray = false;
|
||||
m_particle[i].uniqueStamp = m_uniqueStamp++;
|
||||
|
@ -491,7 +491,7 @@ int CParticle::CreatePart(Math::Vector pos, Math::Vector speed,
|
|||
|
||||
if (!m_particle[i].used)
|
||||
{
|
||||
memset(&m_particle[i], 0, sizeof(Particle));
|
||||
m_particle[i] = Particle();
|
||||
m_particle[i].used = true;
|
||||
m_particle[i].ray = false;
|
||||
m_particle[i].uniqueStamp = m_uniqueStamp++;
|
||||
|
@ -547,7 +547,7 @@ int CParticle::CreateRay(Math::Vector pos, Math::Vector goal,
|
|||
|
||||
if (!m_particle[i].used)
|
||||
{
|
||||
memset(&m_particle[i], 0, sizeof(Particle));
|
||||
m_particle[i] = Particle();
|
||||
m_particle[i].used = true;
|
||||
m_particle[i].ray = true;
|
||||
m_particle[i].uniqueStamp = m_uniqueStamp++;
|
||||
|
|
|
@ -161,7 +161,7 @@ COldObject::COldObject(int id)
|
|||
m_infoReturn = NAN;
|
||||
m_team = 0;
|
||||
|
||||
memset(&m_character, 0, sizeof(m_character));
|
||||
m_character = Character();
|
||||
m_character.wheelFront = 1.0f;
|
||||
m_character.wheelBack = 1.0f;
|
||||
m_character.wheelLeft = 1.0f;
|
||||
|
|
|
@ -48,11 +48,11 @@ struct Program;
|
|||
|
||||
struct Character
|
||||
{
|
||||
float wheelFront; // position X of the front wheels
|
||||
float wheelBack; // position X of the back wheels
|
||||
float wheelLeft; // position Z of the left wheels
|
||||
float wheelRight; // position Z of the right wheels
|
||||
float height; // normal height on top of ground
|
||||
float wheelFront = 0.0f; // position X of the front wheels
|
||||
float wheelBack = 0.0f; // position X of the back wheels
|
||||
float wheelLeft = 0.0f; // position Z of the left wheels
|
||||
float wheelRight = 0.0f; // position Z of the right wheels
|
||||
float height = 0.0f; // normal height on top of ground
|
||||
Math::Vector posPower; // position of the battery
|
||||
};
|
||||
|
||||
|
|
|
@ -2063,8 +2063,7 @@ bool CTaskGoto::BitmapOpen()
|
|||
BitmapClose();
|
||||
|
||||
m_bmSize = static_cast<int>(3200.0f/BM_DIM_STEP);
|
||||
m_bmArray = new unsigned char[m_bmSize*m_bmSize/8*2];
|
||||
memset(m_bmArray, 0, m_bmSize*m_bmSize/8*2);
|
||||
m_bmArray = new unsigned char[m_bmSize*m_bmSize/8*2]();
|
||||
|
||||
m_bmOffset = m_bmSize/2;
|
||||
m_bmLine = m_bmSize/8;
|
||||
|
|
|
@ -525,7 +525,6 @@ bool CTaskShield::CreateLight(Math::Vector pos)
|
|||
|
||||
if ( !m_engine->GetLightMode() ) return true;
|
||||
|
||||
memset(&light, 0, sizeof(light));
|
||||
light.type = Gfx::LIGHT_SPOT;
|
||||
light.ambient = Gfx::Color(0.0f, 0.0f, 0.0f);
|
||||
light.diffuse = Gfx::Color(0.0f, 1.0f, 2.0f);
|
||||
|
|
|
@ -358,8 +358,7 @@ bool CScript::Run()
|
|||
|
||||
if ( m_bStepMode ) // step by step mode?
|
||||
{
|
||||
Event newEvent;
|
||||
memset(&newEvent, 0, sizeof(Event));
|
||||
Event newEvent;
|
||||
Step(newEvent);
|
||||
}
|
||||
|
||||
|
|
|
@ -101,7 +101,7 @@ CEdit::CEdit () : CControl ()
|
|||
m_text = std::vector<char>(m_maxChar+1, '\0');
|
||||
m_len = 0;
|
||||
|
||||
memset(m_lineOffset, 0, sizeof(int) * EDITLINEMAX);
|
||||
std::fill_n(m_lineOffset, EDITLINEMAX, 0);
|
||||
|
||||
m_fontType = Gfx::FONT_COURIER;
|
||||
m_scroll = 0;
|
||||
|
|
|
@ -321,11 +321,9 @@ void CScreenLevelList::UpdateSceneChap(int &chap)
|
|||
CList* pl;
|
||||
|
||||
std::string fileName;
|
||||
char line[500];
|
||||
char line[500] = {0};
|
||||
bool bPassed;
|
||||
|
||||
memset(line, 0, 500);
|
||||
|
||||
pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5));
|
||||
if ( pw == 0 ) return;
|
||||
pl = static_cast<CList*>(pw->SearchControl(EVENT_INTERFACE_CHAP));
|
||||
|
@ -403,12 +401,10 @@ void CScreenLevelList::UpdateSceneList(int chap, int &sel)
|
|||
CWindow* pw;
|
||||
CList* pl;
|
||||
std::string fileName;
|
||||
char line[500];
|
||||
char line[500] = {0};
|
||||
int j;
|
||||
bool bPassed;
|
||||
|
||||
memset(line, 0, 500);
|
||||
|
||||
pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5));
|
||||
if ( pw == 0 ) return;
|
||||
pl = static_cast<CList*>(pw->SearchControl(EVENT_INTERFACE_LIST));
|
||||
|
|
Loading…
Reference in New Issue