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

Home » Public Forums » archive » Re: 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
Re: copying pointers in structures [message #82601] Mon, 07 January 2013 09:44
Helder Marchetto is currently offline  Helder Marchetto
Messages: 520
Registered: November 2011
Senior Member
On Monday, January 7, 2013 6:27:02 PM UTC+1, Helder wrote:
> 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

Ok, ok, it seems like my search as come to a success... save and restore seem to do the work... I simply had to look for copying of objects instead of pointers.

Thanks anyway.
Cheers,
Helder
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: copying pointers in structures
Next Topic: Re: compare 2-d array with vector

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

Current Time: Wed Oct 08 18:36:00 PDT 2025

Total time taken to generate the page: 0.00356 seconds