            MemorySegment resultPtr = (MemorySegment) {{ ffi_handle }}.invoke({{ args_joined }});
{{ named_frees }}            if (resultPtr.equals(MemorySegment.NULL)) {
                checkLastFfiError();
                return null;
            }
            try {
                String result = resultPtr.reinterpret(Long.MAX_VALUE).getString(0);
                return result;
            } finally {
                NativeLib.{{ prefix_upper }}_FREE_STRING.invoke(resultPtr);
            }
