Changeset 110
- Timestamp:
- 12/31/2006 18:00:41 (23 months ago)
- Location:
- trunk/ext/sand_table
- Files:
-
- 2 modified
-
sand_table.c (modified) (6 diffs)
-
sand_table.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ext/sand_table/sand_table.c
r105 r110 17 17 18 18 static VALUE Qimport, Qinit, Qload, Qenv, Qio, Qreal, Qref, Qall; 19 VALUE rb_cSandbox, rb_cSandboxFull, rb_cSandboxSafe, rb_eSandboxException, rb_cSandboxRef ;19 VALUE rb_cSandbox, rb_cSandboxFull, rb_cSandboxSafe, rb_eSandboxException, rb_cSandboxRef, rb_cSandwick; 20 20 static ID s_options; 21 21 … … 317 317 } sandtransfer; 318 318 319 void 320 mark_sandwick(wick) 321 sandwick *wick; 322 { 323 int i; 324 for ( i = 0 ; i < wick->argc ; i++ ) { 325 rb_gc_mark_maybe(wick->argv[i]); 326 } 327 rb_gc_mark(wick->link); 328 rb_gc_mark(wick->exception); 329 if (wick->kit) { 330 rb_gc_mark(wick->kit->self); 331 } 332 rb_gc_mark(wick->banished); 333 /* TODO: mark wick->scope and wick->dyna_vars */ 334 } 335 336 void 337 free_sandwick(wick) 338 sandwick *wick; 339 { 340 rb_gc_unregister_address(&wick->self); 341 free(wick); 342 } 343 344 sandwick * 345 alloc_sandwick() 346 { 347 sandwick *wick; 348 wick = (sandwick *)malloc(sizeof(sandwick)); 349 wick->self = Qnil; 350 wick->argc = 0; 351 wick->argv = NULL; 352 wick->link = Qnil; 353 wick->action = NULL; 354 wick->exception = Qnil; 355 wick->kit = NULL; 356 wick->banished = Qnil; 357 wick->scope = NULL; 358 wick->dyna_vars = NULL; 359 360 rb_gc_register_address(&wick->self); 361 wick->self = Data_Wrap_Struct(rb_cSandwick, mark_sandwick, free_sandwick, wick); 362 363 return wick; 364 } 365 319 366 /* 320 367 * A "wick" for starting a sandbox that calls … … 328 375 VALUE *argv; 329 376 { 330 sandwick *wick = ALLOC(sandwick);377 sandwick *wick = alloc_sandwick(); 331 378 wick->calltype = SANDBOX_METHOD_CALL; 332 wick->action = NULL;333 379 wick->link = link; 334 380 wick->argc = argc; … … 355 401 VALUE str; 356 402 { 357 sandwick *wick = ALLOC(sandwick);403 sandwick *wick = alloc_sandwick(); 358 404 wick->calltype = SANDBOX_EVAL; 359 wick->action = NULL;360 405 wick->link = str; 361 wick->argc = 0;362 wick->argv = NULL;363 406 return wick; 364 407 } … … 686 729 } 687 730 sandbox_off( wick ); 688 free ( wick );731 free_sandwick( wick ); 689 732 if (!NIL_P(exc)) 690 733 { … … 2960 3003 Init_kit_real(&base, 0); 2961 3004 3005 rb_cSandwick = rb_class_new(rb_cObject); 3006 2962 3007 rb_cSandbox = rb_define_module("Sandbox"); 2963 3008 rb_cSandboxFull = rb_define_class_under(rb_cSandbox, "Full", rb_cObject); -
trunk/ext/sand_table/sand_table.h
r108 r110 173 173 */ 174 174 typedef struct { 175 VALUE self; 176 175 177 /* how is the sandbox to be called? */ 176 178 char calltype;
