From: Yukihiro Matsumoto Date: 2004-09-06T18:13:43+09:00 Subject: Re: [PATCH] dir.c --- Dir.chdir error handling Hi, In message "Re: [PATCH] dir.c --- Dir.chdir error handling" on Mon, 6 Sep 2004 17:28:46 +0900, nobu.nokada@softhome.net writes: |Rather, shouldn't rb_ensure guarantee the argument? Hmm, you mean like this? --- dir.c 19 Aug 2004 07:33:15 -0000 1.125 +++ dir.c 6 Sep 2004 09:12:59 -0000 @@ -690,2 +689,13 @@ static VALUE chdir_thread = Qnil; static VALUE +chdir_yield(args) + VALUE *args; +{ + VALUE dist = args[0]; + VALUE path = args[1]; + + dir_chdir(dist); + return rb_yield(path); +} + +static VALUE chdir_restore(path) @@ -697,3 +707,2 @@ chdir_restore(path) dir_chdir(path); - free(path); return Qnil; @@ -769,2 +778,4 @@ dir_s_chdir(argc, argv, obj) char *cwd = my_getcwd(); + VALUE args[2]; + chdir_blocking++; @@ -772,4 +783,5 @@ dir_s_chdir(argc, argv, obj) chdir_thread = rb_thread_current(); - dir_chdir(dist); - return rb_ensure(rb_yield, path, chdir_restore, (VALUE)cwd); + args[0] = dist; + args[1] = path; + return rb_ensure(chdir_yield, (VALUE)args, chdir_restore, (VALUE)cwd); }