free lv2 ports slice

This commit is contained in:
Luna 2020-08-18 21:02:43 -03:00
parent 7097334201
commit 5e8093b26f
2 changed files with 3 additions and 0 deletions

View file

@ -307,6 +307,7 @@ pub const Image = struct {
defer ctx.deinit(); defer ctx.deinit();
var ports = try lv2.setupPorts(&ctx); var ports = try lv2.setupPorts(&ctx);
defer ctx.allocator.free(ports);
if (ctx.n_audio_in > 2) { if (ctx.n_audio_in > 2) {
std.debug.warn("plugin <{}> has more than two inputs.\n", .{plugin_uri}); std.debug.warn("plugin <{}> has more than two inputs.\n", .{plugin_uri});

View file

@ -59,6 +59,8 @@ pub const Port = struct {
/// Setup ports for a given plugin. Gives an array to pointers of Port structs. /// Setup ports for a given plugin. Gives an array to pointers of Port structs.
/// This setup is required so we link the plugin to the ports later on, and /// This setup is required so we link the plugin to the ports later on, and
/// also link our buffers, and control values. /// also link our buffers, and control values.
///
/// Caller owns returned memory.
pub fn setupPorts(ctx: *plugin.Context) ![]Port { pub fn setupPorts(ctx: *plugin.Context) ![]Port {
var world = ctx.world; var world = ctx.world;
const n_ports: u32 = c.lilv_plugin_get_num_ports(ctx.plugin); const n_ports: u32 = c.lilv_plugin_get_num_ports(ctx.plugin);