You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-04 12:00:25 +00:00
Zero initialize all pointer class and struct members
This prevents the pitfall of UB when checking if they have been assigned something valid by comparing to nullptr.
This commit is contained in:
@@ -83,10 +83,10 @@ public:
|
||||
Transform2D light_shader_xform;
|
||||
//Vector2 light_shader_pos;
|
||||
|
||||
Light *shadows_next_ptr;
|
||||
Light *filter_next_ptr;
|
||||
Light *next_ptr;
|
||||
Light *directional_next_ptr;
|
||||
Light *shadows_next_ptr = nullptr;
|
||||
Light *filter_next_ptr = nullptr;
|
||||
Light *next_ptr = nullptr;
|
||||
Light *directional_next_ptr = nullptr;
|
||||
|
||||
RID light_internal;
|
||||
uint64_t version;
|
||||
@@ -168,7 +168,7 @@ public:
|
||||
MAX_SIZE = 4096
|
||||
};
|
||||
uint32_t usage;
|
||||
uint8_t *memory;
|
||||
uint8_t *memory = nullptr;
|
||||
};
|
||||
|
||||
struct Command {
|
||||
@@ -185,7 +185,7 @@ public:
|
||||
TYPE_ANIMATION_SLICE,
|
||||
};
|
||||
|
||||
Command *next;
|
||||
Command *next = nullptr;
|
||||
Type type;
|
||||
virtual ~Command() {}
|
||||
};
|
||||
@@ -305,8 +305,8 @@ public:
|
||||
};
|
||||
|
||||
struct ViewportRender {
|
||||
RenderingServer *owner;
|
||||
void *udata;
|
||||
RenderingServer *owner = nullptr;
|
||||
void *udata = nullptr;
|
||||
Rect2 rect;
|
||||
};
|
||||
|
||||
@@ -334,22 +334,22 @@ public:
|
||||
RID material;
|
||||
RID skeleton;
|
||||
|
||||
Item *next;
|
||||
Item *next = nullptr;
|
||||
|
||||
struct CopyBackBuffer {
|
||||
Rect2 rect;
|
||||
Rect2 screen_rect;
|
||||
bool full;
|
||||
};
|
||||
CopyBackBuffer *copy_back_buffer;
|
||||
CopyBackBuffer *copy_back_buffer = nullptr;
|
||||
|
||||
Color final_modulate;
|
||||
Transform2D final_transform;
|
||||
Rect2 final_clip_rect;
|
||||
Item *final_clip_owner;
|
||||
Item *material_owner;
|
||||
Item *canvas_group_owner;
|
||||
ViewportRender *vp_render;
|
||||
Item *final_clip_owner = nullptr;
|
||||
Item *material_owner = nullptr;
|
||||
Item *canvas_group_owner = nullptr;
|
||||
ViewportRender *vp_render = nullptr;
|
||||
bool distance_field;
|
||||
bool light_masked;
|
||||
|
||||
@@ -453,14 +453,14 @@ public:
|
||||
return rect;
|
||||
}
|
||||
|
||||
Command *commands;
|
||||
Command *last_command;
|
||||
Command *commands = nullptr;
|
||||
Command *last_command = nullptr;
|
||||
Vector<CommandBlock> blocks;
|
||||
uint32_t current_block;
|
||||
|
||||
template <class T>
|
||||
T *alloc_command() {
|
||||
T *command;
|
||||
T *command = nullptr;
|
||||
if (commands == nullptr) {
|
||||
// As the most common use case of canvas items is to
|
||||
// use only one command, the first is done with it's
|
||||
@@ -590,7 +590,7 @@ public:
|
||||
bool sdf_collision;
|
||||
RS::CanvasOccluderPolygonCullMode cull_cache;
|
||||
|
||||
LightOccluderInstance *next;
|
||||
LightOccluderInstance *next = nullptr;
|
||||
|
||||
LightOccluderInstance() {
|
||||
enabled = true;
|
||||
|
||||
Reference in New Issue
Block a user