On Sun, 07 Mar 2004 23:49:09 +0900, ts wrote: > Now there is rb_hash_aref() but it use st_insert() rather than > rb_hash_aset(). The reason is simple, plruby can run with $SAFE >= 4 > and in this case ruby will give an error > > svg% ruby -e 'a = {}; $SAFE = 4; a[12] = 24' -e:1:in `[]=': Insecure: > can't modify hash (SecurityError) > from -e:1 > svg% > > because I'm *sure* that it don't exist a security problem in this case > it use st_insert() rather than the standard API function to bypass the > security mechanism Today I see that I my original post was terse to the point of being incomprehensible. What I was trying to ask was "How do I support the freeze method in my C extension? That is, suppose a script calls the freeze method on one of my objects, and then uses a method that modifies that object. What should I do?" I examined the Ruby sources and discovered the "rb_check_frozen" function. This function tests the frozen state of the object and if the object is frozen, raises a TypeError exception. So I suppose that every method in my classes that modifies the object should call rb_check_frozen to make sure the object isn't frozen before proceeding. I poked around a bit in the code that implements the built-in classes (for example, array.c) and see that this seems to be the case. To confirm my plan I started looking at the code for the standard libraries that are written in C, but I saw very few calls to rb_check_frozen. This makes me wonder, have I misunderstood how to support frozen objects in C?