[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

memory marking problem

Joe Bacigalupa

8/4/2006 3:53:00 PM

I'm pretty new to Ruby and running into some odd issues with my "mark"
function. Basically I have a situation like this
[code]
void ruby_node_free( void* ptr ){
delete reinterpret_cast<Node*>( ptr );
}
void ruby_node_mark( VALUE self ){
Node* ptr = reinterpret_cast<Node*>(DATA_PTR(self));
if( ptr ){
// these are all ruby arrays
rb_gc_mark( ptr->verts );
rb_gc_mark( ptr->normals );
rb_gc_mark( ptr->uvw );
}
}
void ruby_node_alloc( VALUE klass ){
Node* ptr = new Node;
VALUE object = Data_Wrap_Struct( klass, ruby_node_mark,
ruby_node_free, ptr );
return( object );
}
[/code]

What happens is when my ruby_node_mark function is called and I grab the
Node* that value is some chode memory value like 0xfdfdfdfd. I'm
wondering if anyone has run into any problems like this where it seems
that some variables are being deleted twice or something like that.

--
Posted via http://www.ruby-....

2 Answers

ts

8/4/2006 4:06:00 PM

0

>>>>> "J" == Joe Bacigalupa <joeb@asgvis.com> writes:

J> void ruby_node_free( void* ptr ){
J> delete reinterpret_cast<Node*>( ptr );
J> }
J> void ruby_node_mark( VALUE self ){
J> Node* ptr = reinterpret_cast<Node*>(DATA_PTR(self));

The mark function take the same argument than the free function, void *ptr
in your case.


Guy Decoux

Joe Bacigalupa

8/4/2006 4:41:00 PM

0

ts wrote:
>>>>>> "J" == Joe Bacigalupa <joeb@asgvis.com> writes:
>
> J> void ruby_node_free( void* ptr ){
> J> delete reinterpret_cast<Node*>( ptr );
> J> }
> J> void ruby_node_mark( VALUE self ){
> J> Node* ptr = reinterpret_cast<Node*>(DATA_PTR(self));
>
> The mark function take the same argument than the free function, void
> *ptr
> in your case.
>
>
> Guy Decoux

Thanks - that was it - I don't know how I managed to breeze by that
glaring error =) Thank you!

Joe


--
Posted via http://www.ruby-....