comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » copying pointers in structures
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
copying pointers in structures [message #82602] Mon, 07 January 2013 09:27
Helder Marchetto is currently offline  Helder Marchetto
Messages: 520
Registered: November 2011
Senior Member
Hi,
I read some of the previous posts, but I think that I'm not using the right keywords or not understanding...
Well, I have a structure that I would like to temporarily save to eventually restore later on. Now the problem is that when making a copy of a structure with pointers I only copy the reference and not the value, so restoring my values will not work.
Is there a better/quicker way to do this:
a = {data:ptr_new(10), number:0}
b = a
b.data = ptr_new(*a.data)

This way, when I modify a.data with:
*a.data = 0
and want to restore it, I just use:
a = b
and a.data will now be again 10

Is there a programmatic way to do this without knowing the content of the structure? A sort of deep_duplicate_structure or whatever?

Thanks,
Helder
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: Was a file opened with /Swap_if_little_endian ?
Next Topic: Re: copying pointers in structures

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 18:41:06 PDT 2025

Total time taken to generate the page: 0.00673 seconds