0

I have the following structures defined:

point_str={loop_point, x:0d, y:0d}
loop_time_str={loop_time_struct, points:ptr_new(/allocate_heap), loop_id:0d, time:0d}
loop_str={loop_struct,time_series:replicate(loop_time_str, num_images), loop_id:0d}

Points is an array and because the size of points varies I understand it needs to be a pointer.

Later on I create a new variable:

curr_loop_intime = {loop_time_struct}

I then populate the values.

FOR POINT=0,n_elements(IND)-1 DO BEGIN
  points_arr[POINT].x = X(IND[POINT])
  points_arr[POINT].y = Y(IND[POINT])
ENDFOR

I then try to assign the points array to the loop by doing:

*(curr_loop_intime.points)=ptr_new(points_arr)

But this line gives me the error:

% Unable to dereference NULL pointer: <POINTER  (<NullPointer>)>.

Does anyone have any suggestions?

IainS
  • 260
  • 3
  • 14

1 Answers1

0

It seems like you are trying to assign the pointer-to-points_arr to the dereferenced pointer curr_loop_intime.points [ by surrounding with *() ]. Since curr_loop_intime.points has not previously been assigned to point to anything, IDL is unable to dereference it, and hence the error is thrown.

Try removing the *() from your assignment statement, so that you are assigning the pointer-to-points_arr to the .points structure member, which is declared as a variable of type pointer.

Hope this helps.

wtt
  • 13
  • 1
  • 5