From: Tim Hunter Date: 2005-02-09T22:20:11+09:00 Subject: Re: A couple of Ruby API questions Jon McClintock wrote: > > 2) Wrapping structures with flexible arrays. How do I realloc the > structure held by a VALUE? Or do I have to create an entirely new > Ruby object each time I need to resize the structure? If you have created a VALUE by wrapping a structure with Data_Wrap_Struct or Data_Make_Struct and you need to change the structure that the VALUE wraps, use the DATA_PTR macro: VALUE my_obj; MyStruct my_struct; my_struct = malloc(sizeof(MyStruct)); DATA_PTR(my_obj) = my_struct; As far as Ruby is concerned the object is unchanged. -- Tim Hunter