mirror of
https://github.com/lightpanda-io/browser.git
synced 2026-03-22 04:34:44 +00:00
initialize all App fields after allocator.create
Same pattern as 3dea554e (mcp/Server.zig): allocator.create returns
undefined memory, and struct field defaults (shutdown: bool = false)
are not applied when fields are set individually. Use self.* = .{...}
to ensure all fields including defaults are initialized.
This commit is contained in:
15
src/App.zig
15
src/App.zig
@@ -47,10 +47,17 @@ pub fn init(allocator: Allocator, config: *const Config) !*App {
|
|||||||
const app = try allocator.create(App);
|
const app = try allocator.create(App);
|
||||||
errdefer allocator.destroy(app);
|
errdefer allocator.destroy(app);
|
||||||
|
|
||||||
app.config = config;
|
app.* = .{
|
||||||
app.allocator = allocator;
|
.config = config,
|
||||||
|
.allocator = allocator,
|
||||||
app.robots = RobotStore.init(allocator);
|
.robots = RobotStore.init(allocator),
|
||||||
|
.http = undefined,
|
||||||
|
.platform = undefined,
|
||||||
|
.snapshot = undefined,
|
||||||
|
.app_dir_path = undefined,
|
||||||
|
.telemetry = undefined,
|
||||||
|
.arena_pool = undefined,
|
||||||
|
};
|
||||||
|
|
||||||
app.http = try Http.init(allocator, &app.robots, config);
|
app.http = try Http.init(allocator, &app.robots, config);
|
||||||
errdefer app.http.deinit();
|
errdefer app.http.deinit();
|
||||||
|
|||||||
Reference in New Issue
Block a user