Skip to content

Commit 3ba1a7c

Browse files
committed
Completely remove the privdata mechanism in dialog.h.
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 42c592c)
1 parent 4c24c8d commit 3ba1a7c

File tree

4 files changed

+0
-162
lines changed

4 files changed

+0
-162
lines changed

dialog.h

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -634,21 +634,6 @@ int dlg_coloursel_results(union control *ctrl, void *dlg,
634634
*/
635635
void dlg_refresh(union control *ctrl, void *dlg);
636636

637-
/*
638-
* It's perfectly possible that individual controls might need to
639-
* allocate or store per-dialog-instance data, so here's a
640-
* mechanism.
641-
*
642-
* `dlg_get_privdata' and `dlg_set_privdata' allow the user to get
643-
* and set a void * pointer associated with the control in
644-
* question. `dlg_alloc_privdata' will allocate memory, store a
645-
* pointer to that memory in the private data field, and arrange
646-
* for it to be automatically deallocated on dialog cleanup.
647-
*/
648-
void *dlg_get_privdata(union control *ctrl, void *dlg);
649-
void dlg_set_privdata(union control *ctrl, void *dlg, void *ptr);
650-
void *dlg_alloc_privdata(union control *ctrl, void *dlg, size_t size);
651-
652637
/*
653638
* Standard helper functions for reading a controlbox structure.
654639
*/

macosx/osxctrls.m

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -243,8 +243,6 @@ - (id)initWithStruct:(struct fe_dlg *)aStruct;
243243
NSTableView *tableview;
244244
NSScrollView *scrollview;
245245
int nradiobuttons;
246-
void *privdata;
247-
int privdata_needs_free;
248246
};
249247

250248
static int fe_ctrl_cmp_by_ctrl(void *av, void *bv)
@@ -346,16 +344,12 @@ static int fe_backwards_find_by_widget(void *av, void *bv)
346344
c->scrollview = nil;
347345
c->radiobuttons = NULL;
348346
c->nradiobuttons = 0;
349-
c->privdata = NULL;
350-
c->privdata_needs_free = FALSE;
351347

352348
return c;
353349
}
354350

355351
static void fe_ctrl_free(struct fe_ctrl *c)
356352
{
357-
if (c->privdata_needs_free)
358-
sfree(c->privdata);
359353
sfree(c->radiobuttons);
360354
sfree(c);
361355
}
@@ -1785,31 +1779,3 @@ void dlg_refresh(union control *ctrl, void *dv)
17851779
}
17861780
}
17871781
}
1788-
1789-
void *dlg_get_privdata(union control *ctrl, void *dv)
1790-
{
1791-
struct fe_dlg *d = (struct fe_dlg *)dv;
1792-
struct fe_ctrl *c = fe_ctrl_byctrl(d, ctrl);
1793-
return c->privdata;
1794-
}
1795-
1796-
void dlg_set_privdata(union control *ctrl, void *dv, void *ptr)
1797-
{
1798-
struct fe_dlg *d = (struct fe_dlg *)dv;
1799-
struct fe_ctrl *c = fe_ctrl_byctrl(d, ctrl);
1800-
c->privdata = ptr;
1801-
c->privdata_needs_free = FALSE;
1802-
}
1803-
1804-
void *dlg_alloc_privdata(union control *ctrl, void *dv, size_t size)
1805-
{
1806-
struct fe_dlg *d = (struct fe_dlg *)dv;
1807-
struct fe_ctrl *c = fe_ctrl_byctrl(d, ctrl);
1808-
/*
1809-
* This is an internal allocation routine, so it's allowed to
1810-
* use smalloc directly.
1811-
*/
1812-
c->privdata = smalloc(size);
1813-
c->privdata_needs_free = TRUE;
1814-
return c->privdata;
1815-
}

unix/gtkdlg.c

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,6 @@ struct Shortcuts {
3737
struct uctrl {
3838
union control *ctrl;
3939
GtkWidget *toplevel;
40-
void *privdata;
41-
int privdata_needs_free;
4240
GtkWidget **buttons; int nbuttons; /* for radio buttons */
4341
GtkWidget *entry; /* for editbox, filesel, fontsel */
4442
GtkWidget *button; /* for filesel, fontsel */
@@ -189,8 +187,6 @@ static void dlg_cleanup(struct dlgparam *dp)
189187
dp->byctrl = NULL;
190188
while ( (uc = index234(dp->bywidget, 0)) != NULL) {
191189
del234(dp->bywidget, uc);
192-
if (uc->privdata_needs_free)
193-
sfree(uc->privdata);
194190
sfree(uc->buttons);
195191
sfree(uc);
196192
}
@@ -228,34 +224,6 @@ static struct uctrl *dlg_find_bywidget(struct dlgparam *dp, GtkWidget *w)
228224
return ret;
229225
}
230226

231-
void *dlg_get_privdata(union control *ctrl, void *dlg)
232-
{
233-
struct dlgparam *dp = (struct dlgparam *)dlg;
234-
struct uctrl *uc = dlg_find_byctrl(dp, ctrl);
235-
return uc->privdata;
236-
}
237-
238-
void dlg_set_privdata(union control *ctrl, void *dlg, void *ptr)
239-
{
240-
struct dlgparam *dp = (struct dlgparam *)dlg;
241-
struct uctrl *uc = dlg_find_byctrl(dp, ctrl);
242-
uc->privdata = ptr;
243-
uc->privdata_needs_free = FALSE;
244-
}
245-
246-
void *dlg_alloc_privdata(union control *ctrl, void *dlg, size_t size)
247-
{
248-
struct dlgparam *dp = (struct dlgparam *)dlg;
249-
struct uctrl *uc = dlg_find_byctrl(dp, ctrl);
250-
/*
251-
* This is an internal allocation routine, so it's allowed to
252-
* use smalloc directly.
253-
*/
254-
uc->privdata = smalloc(size);
255-
uc->privdata_needs_free = FALSE;
256-
return uc->privdata;
257-
}
258-
259227
union control *dlg_last_focused(union control *ctrl, void *dlg)
260228
{
261229
struct dlgparam *dp = (struct dlgparam *)dlg;
@@ -1832,8 +1800,6 @@ GtkWidget *layout_ctrls(struct dlgparam *dp, struct Shortcuts *scs,
18321800

18331801
uc = snew(struct uctrl);
18341802
uc->ctrl = ctrl;
1835-
uc->privdata = NULL;
1836-
uc->privdata_needs_free = FALSE;
18371803
uc->buttons = NULL;
18381804
uc->entry = NULL;
18391805
#if !GTK_CHECK_VERSION(2,4,0)

windows/winctrls.c

Lines changed: 0 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -2532,23 +2532,6 @@ void dlg_set_fixed_pitch_flag(void *dlg, int flag)
25322532
dp->fixed_pitch_fonts = flag;
25332533
}
25342534

2535-
struct perctrl_privdata {
2536-
union control *ctrl;
2537-
void *data;
2538-
int needs_free;
2539-
};
2540-
2541-
static int perctrl_privdata_cmp(void *av, void *bv)
2542-
{
2543-
struct perctrl_privdata *a = (struct perctrl_privdata *)av;
2544-
struct perctrl_privdata *b = (struct perctrl_privdata *)bv;
2545-
if (a->ctrl < b->ctrl)
2546-
return -1;
2547-
else if (a->ctrl > b->ctrl)
2548-
return +1;
2549-
return 0;
2550-
}
2551-
25522535
void dp_init(struct dlgparam *dp)
25532536
{
25542537
dp->nctrltrees = 0;
@@ -2558,7 +2541,6 @@ void dp_init(struct dlgparam *dp)
25582541
memset(dp->shortcuts, 0, sizeof(dp->shortcuts));
25592542
dp->hwnd = NULL;
25602543
dp->wintitle = dp->errtitle = NULL;
2561-
dp->privdata = newtree234(perctrl_privdata_cmp);
25622544
dp->fixed_pitch_fonts = TRUE;
25632545
}
25642546

@@ -2570,67 +2552,6 @@ void dp_add_tree(struct dlgparam *dp, struct winctrls *wc)
25702552

25712553
void dp_cleanup(struct dlgparam *dp)
25722554
{
2573-
struct perctrl_privdata *p;
2574-
2575-
if (dp->privdata) {
2576-
while ( (p = index234(dp->privdata, 0)) != NULL ) {
2577-
del234(dp->privdata, p);
2578-
if (p->needs_free)
2579-
sfree(p->data);
2580-
sfree(p);
2581-
}
2582-
freetree234(dp->privdata);
2583-
dp->privdata = NULL;
2584-
}
25852555
sfree(dp->wintitle);
25862556
sfree(dp->errtitle);
25872557
}
2588-
2589-
void *dlg_get_privdata(union control *ctrl, void *dlg)
2590-
{
2591-
struct dlgparam *dp = (struct dlgparam *)dlg;
2592-
struct perctrl_privdata tmp, *p;
2593-
tmp.ctrl = ctrl;
2594-
p = find234(dp->privdata, &tmp, NULL);
2595-
if (p)
2596-
return p->data;
2597-
else
2598-
return NULL;
2599-
}
2600-
2601-
void dlg_set_privdata(union control *ctrl, void *dlg, void *ptr)
2602-
{
2603-
struct dlgparam *dp = (struct dlgparam *)dlg;
2604-
struct perctrl_privdata tmp, *p;
2605-
tmp.ctrl = ctrl;
2606-
p = find234(dp->privdata, &tmp, NULL);
2607-
if (!p) {
2608-
p = snew(struct perctrl_privdata);
2609-
p->ctrl = ctrl;
2610-
p->needs_free = FALSE;
2611-
add234(dp->privdata, p);
2612-
}
2613-
p->data = ptr;
2614-
}
2615-
2616-
void *dlg_alloc_privdata(union control *ctrl, void *dlg, size_t size)
2617-
{
2618-
struct dlgparam *dp = (struct dlgparam *)dlg;
2619-
struct perctrl_privdata tmp, *p;
2620-
tmp.ctrl = ctrl;
2621-
p = find234(dp->privdata, &tmp, NULL);
2622-
if (!p) {
2623-
p = snew(struct perctrl_privdata);
2624-
p->ctrl = ctrl;
2625-
p->needs_free = FALSE;
2626-
add234(dp->privdata, p);
2627-
}
2628-
assert(!p->needs_free);
2629-
p->needs_free = TRUE;
2630-
/*
2631-
* This is an internal allocation routine, so it's allowed to
2632-
* use smalloc directly.
2633-
*/
2634-
p->data = smalloc(size);
2635-
return p->data;
2636-
}

0 commit comments

Comments
 (0)