Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 4 additions & 8 deletions src/objects/lfunc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,8 @@


// Constructor
CClosure::CClosure(int nupvals) {
nupvalues = cast_byte(nupvals);
gclist = nullptr;
f = nullptr;
CClosure::CClosure(int nupvals)
: nupvalues(cast_byte(nupvals)), gclist(nullptr), f(nullptr) {
// upvalue array initialized by caller if needed
}

Expand All @@ -42,10 +40,8 @@ CClosure* CClosure::create(lua_State* L, int nupvals) {


// Constructor
LClosure::LClosure(int nupvals) {
nupvalues = cast_byte(nupvals);
gclist = nullptr;
p = nullptr;
LClosure::LClosure(int nupvals)
: nupvalues(cast_byte(nupvals)), gclist(nullptr), p(nullptr) {
// Initialize upvals array to nullptr
std::fill_n(upvals, nupvals, nullptr);
}
Expand Down
4 changes: 2 additions & 2 deletions src/objects/lfunc.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ class UpVal : public GCBase<UpVal> {

public:
// Phase 50: Constructor - initializes all fields to safe defaults
UpVal() noexcept {
v.p = nullptr; // Initialize v union (pointer variant)
UpVal() noexcept
: v{nullptr}, u{} {
// Initialize u union as closed upvalue with nil
u.value.valueField().n = 0; // Zero-initialize Value union
u.value.setType(LUA_TNIL);
Expand Down
7 changes: 2 additions & 5 deletions src/objects/lobject_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -364,11 +364,8 @@ class Udata : public GCBase<Udata> {

public:
// Phase 50: Constructor - initializes all fields to safe defaults
Udata() noexcept {
nuvalue = 0;
len = 0;
metatable = nullptr;
gclist = nullptr;
Udata() noexcept
: nuvalue(0), len(0), metatable(nullptr), gclist(nullptr) {
// Note: uv array will be initialized by caller if needed
}

Expand Down
18 changes: 4 additions & 14 deletions src/objects/lproto.h
Original file line number Diff line number Diff line change
Expand Up @@ -218,20 +218,10 @@ class Proto : public GCBase<Proto> {

public:
// Phase 50: Constructor - initializes all fields to safe defaults
Proto() noexcept {
numparams = 0;
flag = 0;
maxstacksize = 0;
sizeupvalues = 0;
sizek = 0;
sizecode = 0;
sizep = 0;
k = nullptr;
code = nullptr;
p = nullptr;
upvalues = nullptr;
gclist = nullptr;

Proto() noexcept
: numparams(0), flag(0), maxstacksize(0), sizeupvalues(0),
sizek(0), sizecode(0), sizep(0), k(nullptr), code(nullptr),
p(nullptr), upvalues(nullptr), gclist(nullptr), debugInfo() {
// Initialize debug info subsystem
debugInfo.setLineInfoSize(0);
debugInfo.setAbsLineInfoSize(0);
Expand Down
7 changes: 2 additions & 5 deletions src/objects/lstring.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,8 @@ class TString : public GCBase<TString> {
// Phase 50: Constructor - initializes only fields common to both short and long strings
// For short strings: only fields up to 'u' exist (contents/falloc/ud are overlay for string data)
// For long strings: all fields exist
TString() noexcept {
extra = 0;
shrlen = 0;
hash = 0;
u.lnglen = 0; // Zero-initialize union
TString() noexcept
: extra(0), shrlen(0), hash(0), u{0} {
// Note: contents, falloc, ud are NOT initialized here!
// They will be initialized by the caller only for long strings.
}
Expand Down
11 changes: 3 additions & 8 deletions src/objects/ltable.h
Original file line number Diff line number Diff line change
Expand Up @@ -162,14 +162,9 @@ class Table : public GCBase<Table> {

public:
// Phase 50: Constructor - initializes all fields to safe defaults
Table() noexcept {
flags = 0;
lsizenode = 0;
asize = 0;
array = nullptr;
node = nullptr;
metatable = nullptr;
gclist = nullptr;
Table() noexcept
: flags(0), lsizenode(0), asize(0), array(nullptr),
node(nullptr), metatable(nullptr), gclist(nullptr) {
}

// Phase 50: Destructor - trivial (GC handles deallocation)
Expand Down
Loading