Sha256: 4fa4146c5ef631a46d442610ba0f7374e948fe1809a7556548665b96f56a834d
Contents?: true
Size: 1018 Bytes
Versions: 2
Compression:
Stored size: 1018 Bytes
Contents
/* Functions useful for interfacing shared rbuf objects with the Ruby GC. */ /* Author: Sameer Deshmukh (@v0dro) */ #include "ruby_ndtypes_internal.h" #define GC_GUARD_TABLE_NAME "@__gc_guard_table" static ID id_gc_guard_table; /* Unregister an NDT object-rbuf pair from the GC guard. */ void rb_ndtypes_gc_guard_unregister(NdtObject *ndt) { VALUE table = rb_ivar_get(mNDTypes_GCGuard, id_gc_guard_table); rb_hash_delete(table, PTR2NUM(ndt)); } /* Register a NDT-rbuf pair in the GC guard. */ void rb_ndtypes_gc_guard_register(NdtObject *ndt, VALUE rbuf) { VALUE table = rb_ivar_get(mNDTypes_GCGuard, id_gc_guard_table); if (table == Qnil) { rb_raise(rb_eLoadError, "GC guard not initialized."); } rb_hash_aset(table, PTR2NUM(ndt), rbuf); } /* Initialize the global GC guard table. klass is a VALUE reprensenting NDTypes class. */ void rb_ndtypes_init_gc_guard(void) { id_gc_guard_table = rb_intern(GC_GUARD_TABLE_NAME); rb_ivar_set(mNDTypes_GCGuard, id_gc_guard_table, rb_hash_new()); }
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
ndtypes-0.2.0dev5 | ext/ruby_ndtypes/gc_guard.c |
ndtypes-0.2.0dev4 | ext/ruby_ndtypes/gc_guard.c |