From: John Melton - G0ORX/N6LYT Date: Mon, 19 Dec 2016 21:43:25 +0000 (+0000) Subject: fix memory leak X-Git-Url: https://git.rkrishnan.org/pf/$rel_link?a=commitdiff_plain;h=fd27b3933f03d890fcc75db8a6bdec4b99d5b5bf;p=pihpsdr.git fix memory leak --- diff --git a/gpio.c b/gpio.c index 6dbce48..c9ac3be 100644 --- a/gpio.c +++ b/gpio.c @@ -245,6 +245,7 @@ static void lockAlert(int gpio, int level, uint32_t tick) { } static void cwAlert(int gpio, int level, uint32_t tick) { +fprintf(stderr,"cwAlert: gpio=%d level=%d internal=%d\n",gpio,level,cw_keyer_internal); if (cw_keyer_internal == 0) keyer_event(gpio, cw_active_level == 0 ? level : (level==0)); } @@ -726,6 +727,7 @@ fprintf(stderr,"encoder_init\n"); } #endif +fprintf(stderr,"GPIO: ENABLE_CW_BUTTONS=%d CWL_BUTTON=%d CWR_BUTTON=%d\n",ENABLE_CW_BUTTONS, CWL_BUTTON, CWR_BUTTON); if(ENABLE_CW_BUTTONS) { setup_button(CWL_BUTTON, cwAlert); setup_button(CWR_BUTTON, cwAlert); diff --git a/iambic.c b/iambic.c index 35ea9cb..aa94ecf 100644 --- a/iambic.c +++ b/iambic.c @@ -193,8 +193,10 @@ static void* keyer_thread(void *arg) { struct timespec loop_delay; int interval = 1000000; // 1 ms +fprintf(stderr,"keyer_thread\n"); while(running) { sem_wait(&cw_event); + key_state = CHECK; while (key_state != EXITLOOP) { @@ -358,7 +360,9 @@ static void* keyer_thread(void *arg) { } clock_nanosleep(CLOCK_MONOTONIC, TIMER_ABSTIME, &loop_delay, NULL); } + } +fprintf(stderr,"keyer_thread: EXIT\n"); } void keyer_close() { @@ -384,10 +388,27 @@ int keyer_init() { //stack_prefault(); +/* if (wiringPiSetup () < 0) { fprintf(stderr,"pthread_create for keyer_thread failed %d\n", rc); exit(-1); } +*/ + + if (SIDETONE_GPIO) + softToneCreate(SIDETONE_GPIO); + else { + beep_init(); + beep_vol(cw_keyer_sidetone_volume); + } + + rc = sem_init(&cw_event, 0, 0); + rc |= pthread_create(&keyer_thread_id, NULL, keyer_thread, NULL); + running = 1; + if(rc < 0) { + fprintf(stderr,"pthread_create for keyer_thread failed %d\n", rc); + exit(-1); + } return 0; } diff --git a/main.c b/main.c index 53df2ed..0226125 100644 --- a/main.c +++ b/main.c @@ -871,6 +871,7 @@ fprintf(stderr,"reconfigure_display: sliders_init: width:%d height:%d\n",display gtk_widget_show(sliders); } gtk_widget_show_all(sliders); + linein_changed(); y+=SLIDERS_HEIGHT; } else { gtk_widget_hide(sliders); diff --git a/memory.c b/memory.c new file mode 100644 index 0000000..e9f8ff1 --- /dev/null +++ b/memory.c @@ -0,0 +1,27 @@ +/* Copyright (C) +* 2015 - John Melton, G0ORX/N6LYT +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* as published by the Free Software Foundation; either version 2 +* of the License, or (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +* +*/ + +#include +#include + +void show_memory(char *title) { + struct rusage r_usage; + getrusage(RUSAGE_SELF,&r_usage); + fprintf(stderr, "%s: Memory usage: %ld bytes\n",title,r_usage.ru_maxrss); +} diff --git a/memory.h b/memory.h new file mode 100644 index 0000000..fbd75c1 --- /dev/null +++ b/memory.h @@ -0,0 +1,20 @@ +/* Copyright (C) +* 2015 - John Melton, G0ORX/N6LYT +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* as published by the Free Software Foundation; either version 2 +* of the License, or (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +* +*/ + +extern void show_memory(char *title); diff --git a/receiver.h b/receiver.h new file mode 100644 index 0000000..1d91a7e --- /dev/null +++ b/receiver.h @@ -0,0 +1,13 @@ +#define MAX_RECEIVERS 2 + +struct _receiver { + int sample_rate; + int buffer_size; + int band; + int bandstack; + int mode; + int filter; + int audio; +} rx[MAX_RECEIVERS]; + + diff --git a/toolbar.c b/toolbar.c index e37b35f..93b2add 100644 --- a/toolbar.c +++ b/toolbar.c @@ -975,6 +975,8 @@ void lock_cb(GtkWidget *widget, gpointer data) { } void mox_cb(GtkWidget *widget, gpointer data) { + + if(getTune()==1) { setTune(0); } @@ -1209,7 +1211,7 @@ void sim_mox_cb(GtkWidget *widget, gpointer data) { } else { mox_cb((GtkWidget *)NULL, (gpointer)NULL); } - vfo_update(NULL); + //vfo_update(NULL); } void sim_function_cb(GtkWidget *widget, gpointer data) { diff --git a/vfo.c b/vfo.c index 80ab046..3097f1b 100644 --- a/vfo.c +++ b/vfo.c @@ -169,6 +169,7 @@ fprintf(stderr,"vfo_configure_event_cb: width=%d height=%d\n", cr = cairo_create (vfo_surface); cairo_set_source_rgb (cr, 0, 0, 0); cairo_paint (cr); + cairo_destroy(cr); g_idle_add(vfo_update,NULL);