Skip to content

Commit 519c8c6

Browse files
committed
Initializing all member variables.
- These were found through Visual Studio static analysis
1 parent 01fb52b commit 519c8c6

19 files changed

Lines changed: 180 additions & 180 deletions

engine/common/console.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,16 +40,16 @@ enum conVarFlags_e {
4040
// Cvar
4141
class conVar_c {
4242
public:
43-
char* name; // Cvar name
44-
int flags; // Flags
45-
bool mod; // Modified?
43+
char* name = nullptr; // Cvar name
44+
int flags = 0; // Flags
45+
bool mod = false; // Modified?
4646

47-
int intVal; // Integer value
48-
float floatVal; // Float value
49-
char* strVal; // String value
47+
int intVal = 0; // Integer value
48+
float floatVal = 0.f; // Float value
49+
char* strVal = nullptr; // String value
5050

51-
char* defVal; // Default string
52-
int min, max; // Clamp limits
51+
char* defVal = nullptr; // Default string
52+
int min = 0, max = 0; // Clamp limits
5353

5454
conVar_c(IConsole* conHnd);
5555
~conVar_c();

engine/core/core_config.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ bool core_config_c::LoadConfig(const char* cfgName)
193193
}
194194
}
195195

196-
delete cfg;
196+
delete[] cfg;
197197
return false;
198198
}
199199

engine/core/core_image.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ bool targa_c::Save(char* fileName)
313313
}
314314
line.MemOutput(&out);
315315
}
316-
delete packet;
316+
delete[] packet;
317317
} else {
318318
// Raw
319319
for (int y = height - 1; y >= 0; y--) {
@@ -382,8 +382,8 @@ struct jpegError_s: public jpeg_error_mgr {
382382
// JPEG Reading
383383

384384
struct jpegRead_s: public jpeg_source_mgr {
385-
ioStream_c* in;
386-
byte buffer[1024];
385+
ioStream_c* in = nullptr;
386+
byte buffer[1024] = {};
387387
jpegRead_s(ioStream_c* in)
388388
: in(in)
389389
{
@@ -486,7 +486,7 @@ bool jpeg_c::Load(char* fileName)
486486
}
487487
catch (...) {
488488
}
489-
delete rows;
489+
delete[] rows;
490490

491491
jpeg_destroy_decompress(&jdecomp);
492492
return false;
@@ -495,8 +495,8 @@ bool jpeg_c::Load(char* fileName)
495495
// JPEG Writing
496496

497497
struct jpegWrite_s: public jpeg_destination_mgr {
498-
ioStream_c* out;
499-
byte buffer[1024];
498+
ioStream_c* out = nullptr;
499+
byte buffer[1024] = {};
500500
jpegWrite_s(ioStream_c* out)
501501
: out(out)
502502
{
@@ -580,7 +580,7 @@ bool jpeg_c::Save(char* fileName)
580580
catch (...) {
581581
dst.Term(&jcomp);
582582
}
583-
delete rows;
583+
delete[] rows;
584584

585585
jpeg_destroy_compress(&jcomp);
586586
return false;
@@ -907,7 +907,7 @@ bool png_c::Save(char* fileName)
907907
}
908908
png_set_rows(png, pnginfo, rows);
909909
png_write_png(png, pnginfo, PNG_TRANSFORM_IDENTITY, NULL);
910-
delete rows;
910+
delete[] rows;
911911

912912
png_destroy_write_struct(&png, &pnginfo);
913913
return false;
@@ -1113,7 +1113,7 @@ bool blp_c::Load(char* fileName)
11131113

11141114
// Read image
11151115
int isize = 0;
1116-
int numMip;
1116+
int numMip = 0;
11171117
for (int c = 0; c < 16; c++) {
11181118
if (mip.size[c] == 0) {
11191119
numMip = c;

engine/core/core_image.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,11 @@ struct imageInfo_s {
3333
// Image
3434
class image_c {
3535
public:
36-
byte* dat;
37-
dword width;
38-
dword height;
39-
int comp;
40-
int type;
36+
byte* dat = nullptr;
37+
dword width = 0;
38+
dword height = 0;
39+
int comp = 0;
40+
int type = 0;
4141

4242
image_c(IConsole* conHnd = NULL);
4343
~image_c();

engine/core/core_main.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,13 @@ class core_main_c: public core_IMain {
3030
// Encapsulated
3131
core_main_c(sys_IMain* sysHnd);
3232

33-
sys_IMain* sys;
33+
sys_IMain* sys = nullptr;
3434

35-
core_IConfig* config;
36-
core_IVideo* video;
37-
ui_IMain* ui;
35+
core_IConfig* config = nullptr;
36+
core_IVideo* video = nullptr;
37+
ui_IMain* ui = nullptr;
3838

39-
bool initialised;
39+
bool initialised = false;
4040
};
4141

4242
core_IMain* core_IMain::GetHandle(sys_IMain* sysHnd)

engine/render/r_font.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ class r_font_c {
2525
const char* StringCursorInternal(struct f_fontHeight_s* fh, const char* str, int curX);
2626
void DrawTextLine(scp_t pos, int align, int height, col4_t col, const char* str);
2727

28-
class r_renderer_c* renderer;
29-
int numFontHeight;
30-
struct f_fontHeight_s* fontHeights[32];
31-
int maxHeight;
32-
int* fontHeightMap;
28+
class r_renderer_c* renderer = nullptr;
29+
int numFontHeight = 0;
30+
struct f_fontHeight_s *fontHeights[32] = {};
31+
int maxHeight = 0;
32+
int* fontHeightMap = nullptr;
3333
};

engine/render/r_main.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,7 @@ void r_renderer_c::EndFrame()
424424
for (int l = 0; l < numLayer; l++) {
425425
layerSort[l]->Render();
426426
}
427-
delete layerSort;
427+
delete[] layerSort;
428428

429429
glFlush();
430430

@@ -744,7 +744,7 @@ void r_renderer_c::DoScreenshot(image_c* i, char* ext)
744744
for (int y = 0; y < ys; y++, p1+= span, p2-= span) {
745745
memcpy(p2, p1, span);
746746
}
747-
delete sbuf;
747+
delete[] sbuf;
748748

749749
// Set image info
750750
i->dat = ss;

engine/render/r_main.h

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -80,47 +80,47 @@ class r_renderer_c: public r_IRenderer, public conCmdHandler_c {
8080
// Encapsulated
8181
r_renderer_c(sys_IMain* sysHnd);
8282

83-
sys_IMain* sys;
83+
sys_IMain* sys = nullptr;
8484

85-
sys_IOpenGL* openGL;
85+
sys_IOpenGL* openGL = nullptr;
8686

87-
r_ITexManager* texMan; // Texture manager interface
87+
r_ITexManager* texMan = nullptr; // Texture manager interface
8888

89-
const char* st_vendor; // Vendor string
90-
const char* st_renderer;// Renderer string
91-
const char* st_ver; // Version string
92-
const char* st_ext; // Exntension string
89+
const char* st_vendor = nullptr; // Vendor string
90+
const char* st_renderer = nullptr; // Renderer string
91+
const char* st_ver = nullptr; // Version string
92+
const char* st_ext = nullptr; // Exntension string
9393

94-
bool texNonPOT; // Non power-of-2 textures supported?
95-
dword texMaxDim; // Maximum texture dimension
94+
bool texNonPOT = false; // Non power-of-2 textures supported?
95+
dword texMaxDim = 0; // Maximum texture dimension
9696

97-
PFNGLCOMPRESSEDTEXIMAGE2DARBPROC glCompressedTexImage2DARB;
97+
PFNGLCOMPRESSEDTEXIMAGE2DARBPROC glCompressedTexImage2DARB = nullptr;
9898

99-
conVar_c* r_compress;
100-
conVar_c* r_screenshotFormat;
101-
conVar_c* r_layerDebug;
99+
conVar_c* r_compress = nullptr;
100+
conVar_c* r_screenshotFormat = nullptr;
101+
conVar_c* r_layerDebug = nullptr;
102102

103-
r_shaderHnd_c* whiteImage; // White image
103+
r_shaderHnd_c* whiteImage = nullptr; // White image
104104

105-
r_font_c* fonts[F_NUMFONTS]; // Font objects
105+
r_font_c* fonts[F_NUMFONTS] = {}; // Font objects
106106

107-
col4_t drawColor; // Current draw color
107+
col4_t drawColor = {}; // Current draw color
108108

109109
r_viewport_s curViewport; // Current viewport
110110

111-
int numShader;
112-
class r_shader_c* shaderList[R_MAXSHADERS];
111+
int numShader = 0;
112+
class r_shader_c *shaderList[R_MAXSHADERS] = {};
113113

114-
int numLayer;
115-
int layerListSize;
116-
r_layer_c** layerList;
117-
r_layer_c* curLayer;
114+
int numLayer = 0;
115+
int layerListSize = 0;
116+
r_layer_c** layerList = nullptr;
117+
r_layer_c* curLayer = nullptr;
118118

119-
int layerCmdBinCount;
120-
int layerCmdBinSize;
121-
struct r_layerCmd_s** layerCmdBin;
119+
int layerCmdBinCount = 0;
120+
int layerCmdBinSize = 0;
121+
struct r_layerCmd_s** layerCmdBin = nullptr;
122122

123-
int takeScreenshot;
123+
int takeScreenshot = 0;
124124
void DoScreenshot(image_c* i, char* ext);
125125

126126
void C_Screenshot(IConsole* conHnd, args_c &args);

engine/render/r_texture.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -209,9 +209,9 @@ void t_manager_c::ThreadProc()
209209

210210
class t_sampleDim_c {
211211
public:
212-
int max;
213-
int i1, i2;
214-
double w1, w2;
212+
int max = 0;
213+
int i1 = 0, i2 = 0;
214+
double w1 = 0.0, w2 = 0.0;
215215

216216
t_sampleDim_c(int imax)
217217
{

engine/system/sys_main.h

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,12 @@ class thread_c {
3535
// File finder
3636
class find_c {
3737
public:
38-
char fileName[512];
39-
bool isDirectory;
40-
dword fileSize;
41-
unsigned long long modified;
42-
char modifiedDate[256];
43-
char modifiedTime[256];
38+
char fileName[512] = {};
39+
bool isDirectory = false;
40+
dword fileSize = 0;
41+
unsigned long long modified = 0;
42+
char modifiedDate[256] = {};
43+
char modifiedTime[256] = {};
4444

4545
find_c();
4646
~find_c();
@@ -57,16 +57,16 @@ class find_c {
5757
// System Main
5858
class sys_IMain {
5959
public:
60-
IConsole* con;
61-
sys_IConsole* conWin;
62-
sys_IVideo* video;
60+
IConsole* con = nullptr;
61+
sys_IConsole* conWin = nullptr;
62+
sys_IVideo* video = nullptr;
6363

64-
bool x64;
65-
bool debug;
66-
bool debuggerRunning;
67-
int processorCount;
68-
char basePath[512];
69-
char userPath[512];
64+
bool x64 = false;
65+
bool debug = false;
66+
bool debuggerRunning = false;
67+
int processorCount = 0;
68+
char basePath[512] = {};
69+
char userPath[512] = {};
7070

7171
virtual int GetTime() = 0;
7272
virtual void Sleep(int msec) = 0;

0 commit comments

Comments
 (0)