allocateRLStruct was originally intended to be used as follows:
/* Create struct and set num{ints/doubles/chars} to 0*/
observation_t myObservation={0,0,0};
/* Set numints to 2 and allocated the intArray*/
allocateRLStruct(myObservation,2,0,0);
The problem with the code above is that it's not intuitive. People would
expect the following to work:
observation_t myObservation;
allocateRLStruct(myObservation,2,0,0);
This will crash, because the first thing that allocateRLStruct does is call
clearRLStruct, which tries to release any old arrays in the struct to be
sure we're not leaking memory if we're using allocateRLStruct all willy-nilly.
A proposal from Todd Hester is to make two functions:
allocateRLStruct <-- this will work with uninitialized values but will leak
memory if passed a struct with existing arrays.
reallocateRLStruct <-- this will work with initialize values and will not
leak memory if passed a struct with existing arrays.
This seems like a reasonable strategy and I will probably implement it.
Comments anyone?
Original issue reported on code.google.com by brian.ta...@gmail.com on 30 Nov 2008 at 7:38
Original issue reported on code.google.com by
brian.ta...@gmail.com
on 30 Nov 2008 at 7:38