mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-03-21 22:28:37 -05:00
Tidy up 'eventlog_stuff' structure and fix leak.
This is the structure that stores the truncated version of the Event Log data to be displayed by the GTK Event Log dialog. It persists for the lifetime of the parent SSH window, so it was deliberate that it wasn't freed on destruction of the dialog itself, but I also forgot to free it on destruction of the SSH window. (This will be more important in multi-connection process architectures like the OS X port, of course.) While I'm at it, I'll follow my recent practice by exposing the structure tag outside gtkdlg.c so that callers can more easily not confuse it with some other kind of void *.
This commit is contained in:
parent
d624ae2ab5
commit
a3a8b28528
@ -3772,7 +3772,7 @@ struct eventlog_stuff {
|
|||||||
|
|
||||||
static void eventlog_destroy(GtkWidget *widget, gpointer data)
|
static void eventlog_destroy(GtkWidget *widget, gpointer data)
|
||||||
{
|
{
|
||||||
struct eventlog_stuff *es = (struct eventlog_stuff *)data;
|
eventlog_stuff *es = (eventlog_stuff *)data;
|
||||||
|
|
||||||
es->window = NULL;
|
es->window = NULL;
|
||||||
sfree(es->seldata);
|
sfree(es->seldata);
|
||||||
@ -3789,7 +3789,7 @@ static void eventlog_ok_handler(union control *ctrl, dlgparam *dp,
|
|||||||
static void eventlog_list_handler(union control *ctrl, dlgparam *dp,
|
static void eventlog_list_handler(union control *ctrl, dlgparam *dp,
|
||||||
void *data, int event)
|
void *data, int event)
|
||||||
{
|
{
|
||||||
struct eventlog_stuff *es = (struct eventlog_stuff *)data;
|
eventlog_stuff *es = (eventlog_stuff *)data;
|
||||||
|
|
||||||
if (event == EVENT_REFRESH) {
|
if (event == EVENT_REFRESH) {
|
||||||
int i;
|
int i;
|
||||||
@ -3868,7 +3868,7 @@ static void eventlog_list_handler(union control *ctrl, dlgparam *dp,
|
|||||||
void eventlog_selection_get(GtkWidget *widget, GtkSelectionData *seldata,
|
void eventlog_selection_get(GtkWidget *widget, GtkSelectionData *seldata,
|
||||||
guint info, guint time_stamp, gpointer data)
|
guint info, guint time_stamp, gpointer data)
|
||||||
{
|
{
|
||||||
struct eventlog_stuff *es = (struct eventlog_stuff *)data;
|
eventlog_stuff *es = (eventlog_stuff *)data;
|
||||||
|
|
||||||
gtk_selection_data_set(seldata, gtk_selection_data_get_target(seldata), 8,
|
gtk_selection_data_set(seldata, gtk_selection_data_get_target(seldata), 8,
|
||||||
(unsigned char *)es->seldata, es->sellen);
|
(unsigned char *)es->seldata, es->sellen);
|
||||||
@ -3877,7 +3877,7 @@ void eventlog_selection_get(GtkWidget *widget, GtkSelectionData *seldata,
|
|||||||
gint eventlog_selection_clear(GtkWidget *widget, GdkEventSelection *seldata,
|
gint eventlog_selection_clear(GtkWidget *widget, GdkEventSelection *seldata,
|
||||||
gpointer data)
|
gpointer data)
|
||||||
{
|
{
|
||||||
struct eventlog_stuff *es = (struct eventlog_stuff *)data;
|
eventlog_stuff *es = (eventlog_stuff *)data;
|
||||||
struct uctrl *uc;
|
struct uctrl *uc;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -3901,9 +3901,8 @@ gint eventlog_selection_clear(GtkWidget *widget, GdkEventSelection *seldata,
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void showeventlog(void *estuff, void *parentwin)
|
void showeventlog(eventlog_stuff *es, void *parentwin)
|
||||||
{
|
{
|
||||||
struct eventlog_stuff *es = (struct eventlog_stuff *)estuff;
|
|
||||||
GtkWidget *window, *w0, *w1;
|
GtkWidget *window, *w0, *w1;
|
||||||
GtkWidget *parent = GTK_WIDGET(parentwin);
|
GtkWidget *parent = GTK_WIDGET(parentwin);
|
||||||
struct controlset *s0, *s1;
|
struct controlset *s0, *s1;
|
||||||
@ -3984,17 +3983,33 @@ void showeventlog(void *estuff, void *parentwin)
|
|||||||
G_CALLBACK(eventlog_selection_clear), es);
|
G_CALLBACK(eventlog_selection_clear), es);
|
||||||
}
|
}
|
||||||
|
|
||||||
void *eventlogstuff_new(void)
|
eventlog_stuff *eventlogstuff_new(void)
|
||||||
{
|
{
|
||||||
struct eventlog_stuff *es;
|
eventlog_stuff *es = snew(eventlog_stuff);
|
||||||
es = snew(struct eventlog_stuff);
|
|
||||||
memset(es, 0, sizeof(*es));
|
memset(es, 0, sizeof(*es));
|
||||||
return es;
|
return es;
|
||||||
}
|
}
|
||||||
|
|
||||||
void logevent_dlg(void *estuff, const char *string)
|
void eventlogstuff_free(eventlog_stuff *es)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
if (es->events_initial) {
|
||||||
|
for (i = 0; i < LOGEVENT_INITIAL_MAX; i++)
|
||||||
|
sfree(es->events_initial[i]);
|
||||||
|
sfree(es->events_initial);
|
||||||
|
}
|
||||||
|
if (es->events_circular) {
|
||||||
|
for (i = 0; i < LOGEVENT_CIRCULAR_MAX; i++)
|
||||||
|
sfree(es->events_circular[i]);
|
||||||
|
sfree(es->events_circular);
|
||||||
|
}
|
||||||
|
|
||||||
|
sfree(es);
|
||||||
|
}
|
||||||
|
|
||||||
|
void logevent_dlg(eventlog_stuff *es, const char *string)
|
||||||
{
|
{
|
||||||
struct eventlog_stuff *es = (struct eventlog_stuff *)estuff;
|
|
||||||
char timebuf[40];
|
char timebuf[40];
|
||||||
struct tm tm;
|
struct tm tm;
|
||||||
char **location;
|
char **location;
|
||||||
|
@ -165,7 +165,7 @@ struct Frontend {
|
|||||||
int exited;
|
int exited;
|
||||||
struct unicode_data ucsdata;
|
struct unicode_data ucsdata;
|
||||||
Conf *conf;
|
Conf *conf;
|
||||||
void *eventlogstuff;
|
eventlog_stuff *eventlogstuff;
|
||||||
guint32 input_event_time; /* Timestamp of the most recent input event. */
|
guint32 input_event_time; /* Timestamp of the most recent input event. */
|
||||||
GtkWidget *dialogs[DIALOG_SLOT_LIMIT];
|
GtkWidget *dialogs[DIALOG_SLOT_LIMIT];
|
||||||
#if GTK_CHECK_VERSION(3,4,0)
|
#if GTK_CHECK_VERSION(3,4,0)
|
||||||
@ -2470,6 +2470,8 @@ static void delete_inst(Frontend *inst)
|
|||||||
*/
|
*/
|
||||||
delete_callbacks_for_context(inst);
|
delete_callbacks_for_context(inst);
|
||||||
|
|
||||||
|
eventlogstuff_free(inst->eventlogstuff);
|
||||||
|
|
||||||
sfree(inst);
|
sfree(inst);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -219,9 +219,11 @@ GtkWidget *create_config_box(const char *title, Conf *conf,
|
|||||||
#endif
|
#endif
|
||||||
void nonfatal_message_box(void *window, const char *msg);
|
void nonfatal_message_box(void *window, const char *msg);
|
||||||
void about_box(void *window);
|
void about_box(void *window);
|
||||||
void *eventlogstuff_new(void);
|
typedef struct eventlog_stuff eventlog_stuff;
|
||||||
void showeventlog(void *estuff, void *parentwin);
|
eventlog_stuff *eventlogstuff_new(void);
|
||||||
void logevent_dlg(void *estuff, const char *string);
|
void eventlogstuff_free(eventlog_stuff *);
|
||||||
|
void showeventlog(eventlog_stuff *estuff, void *parentwin);
|
||||||
|
void logevent_dlg(eventlog_stuff *estuff, const char *string);
|
||||||
#ifdef MAY_REFER_TO_GTK_IN_HEADERS
|
#ifdef MAY_REFER_TO_GTK_IN_HEADERS
|
||||||
struct message_box_button {
|
struct message_box_button {
|
||||||
const char *title;
|
const char *title;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user