@@ -51,8 +51,8 @@ pub fn init(allocator: std.mem.Allocator) void {
5151
5252 _ = zguiCreateContext (null );
5353
54- temp_buffer = .empty ;
55- temp_buffer .? .resize (allocator , 3 * 1024 + 1 ) catch unreachable ;
54+ temp_buffer = std . ArrayList ( u8 ). init ( allocator ) ;
55+ temp_buffer .? .resize (3 * 1024 + 1 ) catch unreachable ;
5656
5757 if (te_enabled ) {
5858 te .init ();
@@ -70,8 +70,8 @@ pub fn initWithExistingContext(allocator: std.mem.Allocator, ctx: Context) void
7070
7171 zguiSetCurrentContext (ctx );
7272
73- temp_buffer = .empty ;
74- temp_buffer .? .resize (allocator , 3 * 1024 + 1 ) catch unreachable ;
73+ temp_buffer = std . ArrayList ( u8 ). init ( allocator ) ;
74+ temp_buffer .? .resize (3 * 1024 + 1 ) catch unreachable ;
7575
7676 if (te_enabled ) {
7777 te .init ();
@@ -82,7 +82,7 @@ pub fn getCurrentContext() ?Context {
8282}
8383pub fn deinit () void {
8484 if (zguiGetCurrentContext () != null ) {
85- temp_buffer .? .deinit (mem_allocator .? );
85+ temp_buffer .? .deinit ();
8686 zguiDestroyContext (null );
8787
8888 // Must be after destroy imgui context.
@@ -112,15 +112,15 @@ pub fn deinit() void {
112112 }
113113}
114114pub fn initNoContext (allocator : std.mem.Allocator ) void {
115- // Caller must have called deinitNoContext() previously
116- assert (temp_buffer == null );
117-
118- mem_allocator = allocator ;
119- temp_buffer = .empty ;
120- temp_buffer .? .resize (allocator , 3 * 1024 + 1 ) catch unreachable ;
115+ if (temp_buffer == null ) {
116+ temp_buffer = std .ArrayList (u8 ).init (allocator );
117+ temp_buffer .? .resize (3 * 1024 + 1 ) catch unreachable ;
118+ }
121119}
122120pub fn deinitNoContext () void {
123- if (temp_buffer ) | * buf | buf .deinit (mem_allocator .? );
121+ if (temp_buffer ) | buf | {
122+ buf .deinit ();
123+ }
124124}
125125extern fn zguiCreateContext (shared_font_atlas : ? * const anyopaque ) Context ;
126126extern fn zguiDestroyContext (ctx : ? Context ) void ;
@@ -3690,16 +3690,16 @@ extern fn zguiSetNextFrameWantCaptureKeyboard(want_capture_keyboard: bool) void;
36903690// Helpers
36913691//
36923692//--------------------------------------------------------------------------------------------------
3693- var temp_buffer : ? std .ArrayListUnmanaged (u8 ) = null ;
3693+ var temp_buffer : ? std .ArrayList (u8 ) = null ;
36943694
36953695pub fn format (comptime fmt : []const u8 , args : anytype ) []const u8 {
36963696 const len = std .fmt .count (fmt , args );
3697- if (len > temp_buffer .? .items .len ) temp_buffer .? .resize (mem_allocator .? , @intCast (len + 64 )) catch unreachable ;
3697+ if (len > temp_buffer .? .items .len ) temp_buffer .? .resize (@intCast (len + 64 )) catch unreachable ;
36983698 return std .fmt .bufPrint (temp_buffer .? .items , fmt , args ) catch unreachable ;
36993699}
37003700pub fn formatZ (comptime fmt : []const u8 , args : anytype ) [:0 ]const u8 {
37013701 const len = std .fmt .count (fmt ++ "\x00 " , args );
3702- if (len > temp_buffer .? .items .len ) temp_buffer .? .resize (mem_allocator .? , @intCast (len + 64 )) catch unreachable ;
3702+ if (len > temp_buffer .? .items .len ) temp_buffer .? .resize (@intCast (len + 64 )) catch unreachable ;
37033703 return std .fmt .bufPrintZ (temp_buffer .? .items , fmt , args ) catch unreachable ;
37043704}
37053705//--------------------------------------------------------------------------------------------------
0 commit comments