]> asedeno.scripts.mit.edu Git - PuTTY.git/commitdiff
Completely remove the privdata mechanism in dialog.h.
authorSimon Tatham <anakin@pobox.com>
Fri, 8 May 2015 18:04:16 +0000 (19:04 +0100)
committerSimon Tatham <anakin@pobox.com>
Sat, 20 Jun 2015 08:39:14 +0000 (09:39 +0100)
The last use of it, to store the contents of the saved session name
edit box, was removed nearly two years ago in svn r9923 and replaced
by ctrl_alloc_with_free. The mechanism has been unused ever since
then, and I suspect any further uses of it would be a bad idea for the
same reasons, so let's get rid of it.

(cherry picked from commit 42c592c4ef024af30af91241f651f699d6dbff0b)

dialog.h
macosx/osxctrls.m
unix/gtkdlg.c
windows/winctrls.c

index 6f454f566c2e12a1055ac3f497bd082d1c0ac42b..6775167019e886ccda93c3649386375ad9323410 100644 (file)
--- a/dialog.h
+++ b/dialog.h
@@ -634,21 +634,6 @@ int dlg_coloursel_results(union control *ctrl, void *dlg,
  */
 void dlg_refresh(union control *ctrl, void *dlg);
 
-/*
- * It's perfectly possible that individual controls might need to
- * allocate or store per-dialog-instance data, so here's a
- * mechanism.
- * 
- * `dlg_get_privdata' and `dlg_set_privdata' allow the user to get
- * and set a void * pointer associated with the control in
- * question. `dlg_alloc_privdata' will allocate memory, store a
- * pointer to that memory in the private data field, and arrange
- * for it to be automatically deallocated on dialog cleanup.
- */
-void *dlg_get_privdata(union control *ctrl, void *dlg);
-void dlg_set_privdata(union control *ctrl, void *dlg, void *ptr);
-void *dlg_alloc_privdata(union control *ctrl, void *dlg, size_t size);
-
 /*
  * Standard helper functions for reading a controlbox structure.
  */
index 12e813c9058cb0e63a3a04440039b375e786d0fd..b4270f9d4c38a011a7212ccfea3509e210da0728 100644 (file)
@@ -243,8 +243,6 @@ struct fe_ctrl {
     NSTableView *tableview;
     NSScrollView *scrollview;
     int nradiobuttons;
-    void *privdata;
-    int privdata_needs_free;
 };
 
 static int fe_ctrl_cmp_by_ctrl(void *av, void *bv)
@@ -346,16 +344,12 @@ static struct fe_ctrl *fe_ctrl_new(union control *ctrl)
     c->scrollview = nil;
     c->radiobuttons = NULL;
     c->nradiobuttons = 0;
-    c->privdata = NULL;
-    c->privdata_needs_free = FALSE;
 
     return c;
 }
 
 static void fe_ctrl_free(struct fe_ctrl *c)
 {
-    if (c->privdata_needs_free)
-       sfree(c->privdata);
     sfree(c->radiobuttons);
     sfree(c);
 }
@@ -1785,31 +1779,3 @@ void dlg_refresh(union control *ctrl, void *dv)
        }
     }
 }
-
-void *dlg_get_privdata(union control *ctrl, void *dv)
-{
-    struct fe_dlg *d = (struct fe_dlg *)dv;
-    struct fe_ctrl *c = fe_ctrl_byctrl(d, ctrl);
-    return c->privdata;
-}
-
-void dlg_set_privdata(union control *ctrl, void *dv, void *ptr)
-{
-    struct fe_dlg *d = (struct fe_dlg *)dv;
-    struct fe_ctrl *c = fe_ctrl_byctrl(d, ctrl);
-    c->privdata = ptr;
-    c->privdata_needs_free = FALSE;
-}
-
-void *dlg_alloc_privdata(union control *ctrl, void *dv, size_t size)
-{
-    struct fe_dlg *d = (struct fe_dlg *)dv;
-    struct fe_ctrl *c = fe_ctrl_byctrl(d, ctrl);
-    /*
-     * This is an internal allocation routine, so it's allowed to
-     * use smalloc directly.
-     */
-    c->privdata = smalloc(size);
-    c->privdata_needs_free = TRUE;
-    return c->privdata;
-}
index 2b8fec17375c8a18a0aff1c004eb6ea3fdee37a0..86a71cd6cbe66ac7dad919908556194df0a0d99b 100644 (file)
@@ -37,8 +37,6 @@ struct Shortcuts {
 struct uctrl {
     union control *ctrl;
     GtkWidget *toplevel;
-    void *privdata;
-    int privdata_needs_free;
     GtkWidget **buttons; int nbuttons; /* for radio buttons */
     GtkWidget *entry;         /* for editbox, filesel, fontsel */
     GtkWidget *button;        /* for filesel, fontsel */
@@ -189,8 +187,6 @@ static void dlg_cleanup(struct dlgparam *dp)
     dp->byctrl = NULL;
     while ( (uc = index234(dp->bywidget, 0)) != NULL) {
        del234(dp->bywidget, uc);
-       if (uc->privdata_needs_free)
-           sfree(uc->privdata);
        sfree(uc->buttons);
        sfree(uc);
     }
@@ -228,34 +224,6 @@ static struct uctrl *dlg_find_bywidget(struct dlgparam *dp, GtkWidget *w)
     return ret;
 }
 
-void *dlg_get_privdata(union control *ctrl, void *dlg)
-{
-    struct dlgparam *dp = (struct dlgparam *)dlg;
-    struct uctrl *uc = dlg_find_byctrl(dp, ctrl);
-    return uc->privdata;
-}
-
-void dlg_set_privdata(union control *ctrl, void *dlg, void *ptr)
-{
-    struct dlgparam *dp = (struct dlgparam *)dlg;
-    struct uctrl *uc = dlg_find_byctrl(dp, ctrl);
-    uc->privdata = ptr;
-    uc->privdata_needs_free = FALSE;
-}
-
-void *dlg_alloc_privdata(union control *ctrl, void *dlg, size_t size)
-{
-    struct dlgparam *dp = (struct dlgparam *)dlg;
-    struct uctrl *uc = dlg_find_byctrl(dp, ctrl);
-    /*
-     * This is an internal allocation routine, so it's allowed to
-     * use smalloc directly.
-     */
-    uc->privdata = smalloc(size);
-    uc->privdata_needs_free = FALSE;
-    return uc->privdata;
-}
-
 union control *dlg_last_focused(union control *ctrl, void *dlg)
 {
     struct dlgparam *dp = (struct dlgparam *)dlg;
@@ -1832,8 +1800,6 @@ GtkWidget *layout_ctrls(struct dlgparam *dp, struct Shortcuts *scs,
 
        uc = snew(struct uctrl);
        uc->ctrl = ctrl;
-       uc->privdata = NULL;
-       uc->privdata_needs_free = FALSE;
        uc->buttons = NULL;
        uc->entry = NULL;
 #if !GTK_CHECK_VERSION(2,4,0)
index 49c13e8dc2ddfcf9968403afc97d70d6d258a0d2..9bee927472d5fb36bd7e1a653682bd6cbe99e6ba 100644 (file)
@@ -2532,23 +2532,6 @@ void dlg_set_fixed_pitch_flag(void *dlg, int flag)
     dp->fixed_pitch_fonts = flag;
 }
 
-struct perctrl_privdata {
-    union control *ctrl;
-    void *data;
-    int needs_free;
-};
-
-static int perctrl_privdata_cmp(void *av, void *bv)
-{
-    struct perctrl_privdata *a = (struct perctrl_privdata *)av;
-    struct perctrl_privdata *b = (struct perctrl_privdata *)bv;
-    if (a->ctrl < b->ctrl)
-       return -1;
-    else if (a->ctrl > b->ctrl)
-       return +1;
-    return 0;
-}
-
 void dp_init(struct dlgparam *dp)
 {
     dp->nctrltrees = 0;
@@ -2558,7 +2541,6 @@ void dp_init(struct dlgparam *dp)
     memset(dp->shortcuts, 0, sizeof(dp->shortcuts));
     dp->hwnd = NULL;
     dp->wintitle = dp->errtitle = NULL;
-    dp->privdata = newtree234(perctrl_privdata_cmp);
     dp->fixed_pitch_fonts = TRUE;
 }
 
@@ -2570,67 +2552,6 @@ void dp_add_tree(struct dlgparam *dp, struct winctrls *wc)
 
 void dp_cleanup(struct dlgparam *dp)
 {
-    struct perctrl_privdata *p;
-
-    if (dp->privdata) {
-       while ( (p = index234(dp->privdata, 0)) != NULL ) {
-           del234(dp->privdata, p);
-           if (p->needs_free)
-               sfree(p->data);
-           sfree(p);
-       }
-       freetree234(dp->privdata);
-       dp->privdata = NULL;
-    }
     sfree(dp->wintitle);
     sfree(dp->errtitle);
 }
-
-void *dlg_get_privdata(union control *ctrl, void *dlg)
-{
-    struct dlgparam *dp = (struct dlgparam *)dlg;
-    struct perctrl_privdata tmp, *p;
-    tmp.ctrl = ctrl;
-    p = find234(dp->privdata, &tmp, NULL);
-    if (p)
-       return p->data;
-    else
-       return NULL;
-}
-
-void dlg_set_privdata(union control *ctrl, void *dlg, void *ptr)
-{
-    struct dlgparam *dp = (struct dlgparam *)dlg;
-    struct perctrl_privdata tmp, *p;
-    tmp.ctrl = ctrl;
-    p = find234(dp->privdata, &tmp, NULL);
-    if (!p) {
-       p = snew(struct perctrl_privdata);
-       p->ctrl = ctrl;
-       p->needs_free = FALSE;
-       add234(dp->privdata, p);
-    }
-    p->data = ptr;
-}
-
-void *dlg_alloc_privdata(union control *ctrl, void *dlg, size_t size)
-{
-    struct dlgparam *dp = (struct dlgparam *)dlg;
-    struct perctrl_privdata tmp, *p;
-    tmp.ctrl = ctrl;
-    p = find234(dp->privdata, &tmp, NULL);
-    if (!p) {
-       p = snew(struct perctrl_privdata);
-       p->ctrl = ctrl;
-       p->needs_free = FALSE;
-       add234(dp->privdata, p);
-    }
-    assert(!p->needs_free);
-    p->needs_free = TRUE;
-    /*
-     * This is an internal allocation routine, so it's allowed to
-     * use smalloc directly.
-     */
-    p->data = smalloc(size);
-    return p->data;
-}