Modifying DATA_PTR - Is it safe?

In a C extension, is it safe to change the value of the data element
in struct RData via the DATA_PTR macro?

By “safe,” I mean, will it cause Ruby any problems? Will the DATA_PTR
macro be supported in future releases? (I’m at 1.6.7.)

In the source I see statements like

DATA_PTR(dir) = NULL;

in dir.c but nowhere else.

Hi,

···

In message “Modifying DATA_PTR - Is it safe?” on 02/11/23, “Tim Hunter” cyclists@nc.rr.com writes:

In a C extension, is it safe to change the value of the data element
in struct RData via the DATA_PTR macro?

By “safe,” I mean, will it cause Ruby any problems? Will the DATA_PTR
macro be supported in future releases? (I’m at 1.6.7.)

It will not cause any problem, if you process referenced C object
properly. And DATA_PTR is available on 1.7 and will be on 1.8.

						matz.

Thanks, Matz!

···

On Sat, 23 Nov 2002 23:49:27 +0900, Yukihiro Matsumoto wrote:

Hi,

In message “Modifying DATA_PTR - Is it safe?” > on 02/11/23, “Tim Hunter” cyclists@nc.rr.com writes:

In a C extension, is it safe to change the value of the data element
in struct RData via the DATA_PTR macro?

By “safe,” I mean, will it cause Ruby any problems? Will the DATA_PTR
macro be supported in future releases? (I’m at 1.6.7.)

It will not cause any problem, if you process referenced C object
properly. And DATA_PTR is available on 1.7 and will be on 1.8.

  					matz.