output/analog: track and free memory for float conversion buffer
==18779== 800,000 bytes in 196 blocks are definitely lost in loss record 29 of 29 ==18779== at 0x4C29110: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so) ==18779== by 0x4E635C3: receive (analog.c:319) ==18779== by 0x40870B: datafeed_in (session.c:316) ==18779== by 0x4E59D4E: sr_session_send (session.c:1201) ==18779== by 0x4E59F8B: sr_session_send (session.c:1159) ==18779== by 0x4E62595: send_chunk (wav.c:234) ==18779== by 0x4E62A06: process_buffer (wav.c:290) ==18779== by 0x40954A: load_input_file_module (input.c:123) ==18779== by 0x4097AB: load_input_file (input.c:157) ==18779== by 0x40531E: main (main.c:288)
This commit is contained in:
parent
877a6d09d5
commit
2dbe445d55
|
@ -31,6 +31,7 @@ struct context {
|
||||||
int num_enabled_channels;
|
int num_enabled_channels;
|
||||||
GPtrArray *channellist;
|
GPtrArray *channellist;
|
||||||
int digits;
|
int digits;
|
||||||
|
float *fdata;
|
||||||
};
|
};
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
|
@ -64,6 +65,7 @@ static int init(struct sr_output *o, GHashTable *options)
|
||||||
g_ptr_array_add(ctx->channellist, ch->name);
|
g_ptr_array_add(ctx->channellist, ch->name);
|
||||||
ctx->num_enabled_channels++;
|
ctx->num_enabled_channels++;
|
||||||
}
|
}
|
||||||
|
ctx->fdata = NULL;
|
||||||
|
|
||||||
return SR_OK;
|
return SR_OK;
|
||||||
}
|
}
|
||||||
|
@ -316,9 +318,10 @@ static int receive(const struct sr_output *o, const struct sr_datafeed_packet *p
|
||||||
case SR_DF_ANALOG:
|
case SR_DF_ANALOG:
|
||||||
analog = packet->payload;
|
analog = packet->payload;
|
||||||
num_channels = g_slist_length(analog->meaning->channels);
|
num_channels = g_slist_length(analog->meaning->channels);
|
||||||
if (!(fdata = g_try_malloc(
|
if (!(fdata = g_try_realloc(ctx->fdata,
|
||||||
analog->num_samples * num_channels * sizeof(float))))
|
analog->num_samples * num_channels * sizeof(float))))
|
||||||
return SR_ERR_MALLOC;
|
return SR_ERR_MALLOC;
|
||||||
|
ctx->fdata = fdata;
|
||||||
if ((ret = sr_analog_to_float(analog, fdata)) != SR_OK)
|
if ((ret = sr_analog_to_float(analog, fdata)) != SR_OK)
|
||||||
return ret;
|
return ret;
|
||||||
*out = g_string_sized_new(512);
|
*out = g_string_sized_new(512);
|
||||||
|
@ -361,6 +364,7 @@ static int cleanup(struct sr_output *o)
|
||||||
ctx = o->priv;
|
ctx = o->priv;
|
||||||
|
|
||||||
g_ptr_array_free(ctx->channellist, 1);
|
g_ptr_array_free(ctx->channellist, 1);
|
||||||
|
g_free(ctx->fdata);
|
||||||
g_free(ctx);
|
g_free(ctx);
|
||||||
o->priv = NULL;
|
o->priv = NULL;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue