Skip to content

Commit ea7c677

Browse files
committed
feat: merge lasting_allocator and scratch_allocator
The distinction between the two wasn't necessary and in pratice, both allocators always ended up being the same.
1 parent 06857fe commit ea7c677

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+158
-168
lines changed

examples/300-buttons.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ pub fn main() !void {
1313
const NUM_BUTTONS = 300;
1414

1515
// This is only used for additional performance
16-
var label_arena = std.heap.ArenaAllocator.init(capy.internal.scratch_allocator);
16+
var label_arena = std.heap.ArenaAllocator.init(capy.internal.allocator);
1717
defer label_arena.deinit();
1818
const label_allocator = label_arena.child_allocator;
1919

examples/7gui/counter.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ pub fn main() !void {
3838
// Atom.
3939
// However, FormatAtom isn't bi-directional (editing the text field won't change count's value),
4040
// but it remains best fit for this example as the text field is read-only.
41-
var format = try capy.FormattedAtom(capy.internal.lasting_allocator, "{d}", .{&count});
41+
var format = try capy.FormattedAtom(capy.internal.allocator, "{d}", .{&count});
4242
defer format.deinit();
4343

4444
try window.set(capy.alignment(

examples/abc.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ pub fn main() !void {
2424
);
2525

2626
var window = try capy.Window.init();
27-
const format = try capy.FormattedAtom(capy.internal.lasting_allocator, "{d:.3}", .{displayed_temperature});
27+
const format = try capy.FormattedAtom(capy.internal.allocator, "{d:.3}", .{displayed_temperature});
2828
try window.set(capy.column(.{}, .{
2929
capy.label(.{})
3030
.bind("text", format),

examples/balls.zig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ pub fn main() !void {
2828
defer capy.deinit();
2929

3030
defer totalEnergy.deinit();
31-
balls = std.ArrayList(Ball).init(capy.internal.lasting_allocator);
31+
balls = std.ArrayList(Ball).init(capy.internal.allocator);
3232
defer balls.deinit();
3333

3434
// Generate random balls
@@ -54,7 +54,7 @@ pub fn main() !void {
5454
try canvas.addMouseButtonHandler(&onMouseButton);
5555
try canvas.addMouseMotionHandler(&onMouseMotion);
5656

57-
var totalEnergyFormat = try capy.FormattedAtom(capy.internal.lasting_allocator, "Total Kinetic Energy: {d:.2}", .{&totalEnergy});
57+
var totalEnergyFormat = try capy.FormattedAtom(capy.internal.allocator, "Total Kinetic Energy: {d:.2}", .{&totalEnergy});
5858
defer totalEnergyFormat.deinit();
5959

6060
var window = try capy.Window.init();

examples/demo.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ pub fn main() !void {
2828
var somesliderValue = capy.Atom(f32).of(0);
2929
defer somesliderValue.deinit();
3030

31-
const somesliderText = try capy.FormattedAtom(capy.internal.lasting_allocator, "{d:.1}", .{&somesliderValue});
31+
const somesliderText = try capy.FormattedAtom(capy.internal.allocator, "{d:.1}", .{&somesliderValue});
3232
defer somesliderText.deinit();
3333

3434
try window.set(capy.row(.{ .spacing = 0 }, .{

examples/dev-tools.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ const std = @import("std");
22
const capy = @import("capy");
33
pub usingnamespace capy.cross_platform;
44

5-
pub const app_allocator = capy.internal.lasting_allocator;
5+
pub const app_allocator = capy.internal.allocator;
66
var app_window: capy.Window = undefined;
77
var dev_protocol_stream: ?std.net.Stream = null;
88

examples/fade.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ pub fn main() !void {
2727
try capy.init();
2828

2929
var window = try capy.Window.init();
30-
// const imageData = try capy.ImageData.fromBuffer(capy.internal.lasting_allocator, @embedFile("ziglogo.png"));
30+
// const imageData = try capy.ImageData.fromBuffer(capy.internal.allocator, @embedFile("ziglogo.png"));
3131

3232
try window.set(
3333
capy.row(.{}, .{

examples/hacker-news.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ pub usingnamespace capy.cross_platform;
55
const ListModel = struct {
66
/// size is a data wrapper so that we can change it (e.g. implement infinite scrolling)
77
size: capy.Atom(usize) = capy.Atom(usize).of(10),
8-
arena: std.heap.ArenaAllocator = std.heap.ArenaAllocator.init(capy.internal.lasting_allocator),
8+
arena: std.heap.ArenaAllocator = std.heap.ArenaAllocator.init(capy.internal.allocator),
99

1010
pub fn getComponent(self: *ListModel, index: usize) *capy.Label {
1111
return capy.label(.{

examples/many-counters.zig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ const CounterState = struct {
1111
};
1212

1313
fn counter() anyerror!*capy.Alignment {
14-
var state1 = try capy.internal.lasting_allocator.create(CounterState);
14+
var state1 = try capy.internal.allocator.create(CounterState);
1515
state1.* = .{};
16-
const format = try capy.FormattedAtom(capy.internal.lasting_allocator, "{d}", .{&state1.count});
16+
const format = try capy.FormattedAtom(capy.internal.allocator, "{d}", .{&state1.count});
1717
// TODO: when to deinit format?
1818

1919
return capy.alignment(

examples/notepad.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ pub fn main() !void {
2222
}
2323
}.callback);
2424

25-
var label_text = try capy.FormattedAtom(capy.internal.lasting_allocator, "Text length: {d}", .{text_length});
25+
var label_text = try capy.FormattedAtom(capy.internal.allocator, "Text length: {d}", .{text_length});
2626
defer label_text.deinit();
2727

2828
try window.set(capy.column(.{ .spacing = 0 }, .{

0 commit comments

Comments
 (0)