[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: taming the shrew, a.k.a. structure

 david@dfanning.com (David Fanning) wrote:
> > temp = myStruct.array1
> > myStruct.array1 = ptr_new( (*myStruct.array1)[0:1024] )
> > ptr_free, temp
> This really becomes nothing more than this:
>    *myStruct.array1 = (*myStruct.array1)[0:1024]
> There is no need to free the old pointer, make
> a new one etc. Pointers are like IDL variables
> in this respect. They *always* point to the 
> current thing you have pointed them too.

That's a useful thing to know. I didn't realize that IDL would do that 
for you. I guess coming from the world of C, my default reaction is to 
think that pointers are static and you have to make sure to explicitly 
resize them appropriately if that's what you want to do. I guess that 
works with all variables in C, but I'd gotten used to regular variables 
not being static.

Well, guess I can shut my brain off for the day since I've already 
learned something new. =)