From cd777294b990d8cab35d8c68fdb12616fe41e402 Mon Sep 17 00:00:00 2001 From: Skgland Date: Sun, 10 Aug 2025 01:57:28 +0200 Subject: [PATCH] use setup_call_cleanup/3 for with_locals as suggested by triska --- src/lib/ffi.pl | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/lib/ffi.pl b/src/lib/ffi.pl index ab981e82..86c7bdc9 100644 --- a/src/lib/ffi.pl +++ b/src/lib/ffi.pl @@ -54,6 +54,7 @@ And a new window should pop up! :- use_module(library(error)). :- use_module(library(format)). :- use_module(library(dcgs)). +:- use_module(library(iso_ext)). %% foreign_struct(+Name, +Elements). % @@ -144,9 +145,10 @@ array_type(ElemType, Len, ArrayType) :- with_locals(Locals, Goal) :- verify_locals(Locals), - allocate_locals(Locals), - ( catch(Goal, E, (deallocate_locals(Locals), throw(E))) -> deallocate_locals(Locals) - ; deallocate_locals(Locals), false + setup_call_cleanup( + allocate_locals(Locals), + Goal, + deallocate_locals(Locals) ). verify_locals(Locals) :- -- 2.54.0