In message <20050912.104954.92585084.taca / back-street.net> on Mon, 12 Sep 2005 10:49:55 +0900, Takahiro Kambe <taca / back-street.net> wrote: > > なるほど。でもsizeof(FILE)の代わりに1でいいのでしょうか。ま > ここんところは、私もわかりません。(そもそも ext/dl の内容を理解してい > ればよいのでしょうけれど、そこまで到達していませんので。) > > 一応、聞いてみます。 即答がありました。 o FILE型の内部に、Rubyのガベージコレクタの制御下となるポインタは存在し ないはずだ。 o 1という値は、ほんとのsizeof(FILE)よりも小さいということが重要で、 FILEのすぐ後に割り当てられたメモリを逃すことがないからだ。 後半は、あまり自身がないので当人のメールの内容を、以下に(勝手に)付けて おきます。 > > Dose using 1 instead of sizeof(FILE) have no problem? > > Their never should be any pointer into FILE under the control of the > garbage collector, so it should be save. I expect the normal malloc > debugger to cry otherwise, but it is the most reasonable value to use. > The most important property of 1 is that 1 < sizeof(real_FILE), so it > doesn't leak memory allocated directly after a FILE. -- 神戸 隆博(かんべ たかひろ) at 仕事場