Changeset 1b1cd2c
- Timestamp:
- Mar 23, 2010, 5:23:43 PM (14 years ago)
- Branches:
- master, release-1.10, release-1.6, release-1.7, release-1.8, release-1.9
- Children:
- 8dfb59c
- Parents:
- 6b78afb
- git-author:
- Nelson Elhage <nelhage@mit.edu> (03/13/10 21:18:03)
- git-committer:
- Nelson Elhage <nelhage@ksplice.com> (03/23/10 17:23:43)
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
editwin.c
rf449096 r1b1cd2c 37 37 char *command; 38 38 void (*callback)(struct _owl_editwin*); 39 void (*destroy_cbdata)(void *); 39 40 void *cbdata; 40 41 }; … … 58 59 static int oe_copy_region(owl_editwin *e); 59 60 static char *oe_chunk(owl_editwin *e, int start, int end); 61 static void oe_destroy_cbdata(owl_editwin *e); 60 62 61 63 #define INCR 4096 … … 145 147 e->echochar='\0'; 146 148 147 /* We get initialized multiple times, but we need to hold on to148 the callbacks, so we can't NULL them here. */149 /*150 e->command = NULL;151 e->callback = NULL;152 e->cbdata = NULL;153 */154 149 if (win) werase(win); 155 150 } … … 210 205 } 211 206 212 void owl_editwin_set_cbdata(owl_editwin *e, void *data) 213 { 207 static void oe_destroy_cbdata(owl_editwin *e) { 208 if (e->destroy_cbdata) 209 e->destroy_cbdata(e->cbdata); 210 e->cbdata = NULL; 211 e->destroy_cbdata = NULL; 212 } 213 214 void owl_editwin_set_cbdata(owl_editwin *e, void *data, void (*destroy)(void *)) 215 { 216 oe_destroy_cbdata(e); 214 217 e->cbdata = data; 218 e->destroy_cbdata = destroy; 215 219 } 216 220 … … 282 286 owl_free(e->buff); 283 287 owl_editwin_init(e, e->curswin, e->winlines, e->wincols, e->style, e->hist); 288 e->callback = NULL; 289 oe_destroy_cbdata(e); 284 290 } 285 291 -
functions.c
r6b78afb r1b1cd2c 277 277 } 278 278 279 void owl_function_start_edit_win(const char *line, void (*callback)(owl_editwin *), void *data )279 void owl_function_start_edit_win(const char *line, void (*callback)(owl_editwin *), void *data, void (*cleanup)(void *)) 280 280 { 281 281 owl_editwin *e; … … 295 295 owl_global_set_typwin_active(&g); 296 296 297 owl_editwin_set_cbdata(owl_global_get_typwin(&g), data );297 owl_editwin_set_cbdata(owl_global_get_typwin(&g), data, cleanup); 298 298 owl_global_set_buffercallback(&g, callback); 299 299 owl_global_push_context(&g, OWL_CTX_EDITMULTI, e, "editmulti"); … … 312 312 noun); 313 313 314 owl_function_start_edit_win(line, callback, NULL );314 owl_function_start_edit_win(line, callback, NULL, NULL); 315 315 owl_global_set_buffercommand(&g, line); 316 316 } -
perlconfig.c
r8f2d9bf r1b1cd2c 574 574 FREETMPS; 575 575 LEAVE; 576 577 SvREFCNT_dec(cb); 578 owl_editwin_set_cbdata(e, NULL); 576 } 577 578 void owl_perlconfig_dec_refcnt(void *data) 579 { 580 SV *v = data; 581 SvREFCNT_dec(v); 579 582 } 580 583 -
perlglue.xs
r8c59178 r1b1cd2c 179 179 owl_function_start_question(line); 180 180 181 owl_editwin_set_cbdata(owl_global_get_typwin(&g), newSVsv(callback)); 181 owl_editwin_set_cbdata(owl_global_get_typwin(&g), 182 newSVsv(callback), 183 owl_perlconfig_dec_refcnt); 182 184 owl_editwin_set_callback(owl_global_get_typwin(&g), owl_perlconfig_edit_callback); 183 185 } … … 195 197 owl_function_start_password(line); 196 198 197 owl_editwin_set_cbdata(owl_global_get_typwin(&g), newSVsv(callback)); 199 owl_editwin_set_cbdata(owl_global_get_typwin(&g), 200 newSVsv(callback), 201 owl_perlconfig_dec_refcnt); 198 202 owl_editwin_set_callback(owl_global_get_typwin(&g), owl_perlconfig_edit_callback); 199 203 } … … 208 212 croak("Callback must be a subref"); 209 213 210 owl_function_start_edit_win(line, owl_perlconfig_edit_callback, newSVsv(callback)); 214 owl_function_start_edit_win(line, 215 owl_perlconfig_edit_callback, 216 newSVsv(callback), 217 owl_perlconfig_dec_refcnt); 211 218 } 212 219
Note: See TracChangeset
for help on using the changeset viewer.