diff options
Diffstat (limited to 'host/examples/tx_samples_c.c')
-rw-r--r-- | host/examples/tx_samples_c.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/host/examples/tx_samples_c.c b/host/examples/tx_samples_c.c index eab061edb..f9001f2f1 100644 --- a/host/examples/tx_samples_c.c +++ b/host/examples/tx_samples_c.c @@ -185,7 +185,7 @@ int main(int argc, char* argv[]){ uhd_tx_streamer_max_num_samps(tx_streamer, &samps_per_buff) ) fprintf(stderr, "Buffer size in samples: %zu\n", samps_per_buff); - buff = malloc(samps_per_buff * 2 * sizeof(float)); + buff = calloc(sizeof(float), samps_per_buff * 2); buffs_ptr = (const void**)&buff; size_t i = 0; for(i = 0; i < (samps_per_buff*2); i+=2){ @@ -205,7 +205,7 @@ int main(int argc, char* argv[]){ if (stop_signal_called) break; if (total_num_samps > 0 && num_acc_samps >= total_num_samps) break; - EXECUTE_OR_GOTO(free_tx_streamer, + EXECUTE_OR_GOTO(free_buff, uhd_tx_streamer_send(tx_streamer, buffs_ptr, samps_per_buff, &md, 0.1, &num_samps_sent) ) @@ -216,6 +216,9 @@ int main(int argc, char* argv[]){ } } + free_buff: + free(buff); + free_tx_streamer: if(verbose){ fprintf(stderr, "Cleaning up TX streamer.\n"); |