Closed zmughal closed 2 years ago
use Feature::Compat::Defer; use FFI::Platypus::Memory qw(malloc free); sub run { my $ptr = malloc(64); defer { free($ptr); } my $data = do_something($ptr); # do not need to place `free($ptr)` here as it will run through `defer` return $data; }
See:
Feature::Compat::Defer
Scope::OnExit
Scope::Guard
Thanks for writing this down, I put some copy into #384 relating to this.
See:
Feature::Compat::Defer
,Scope::OnExit
,Scope::Guard
, &