I need some help assigning memory to hold an array of structures with variable member arrays. Here is a part of the code

Code:
typedef struct 
{
  double *t_stp;
  int    *grid_id;
  double *lv_x;
  double *lv_y;
  double *lv_z;
}AA;

int idx;

static AA *load;


  if (idx == 0) {
    load = new AA[idx+1];
  }else{
    delete [] load;
    load = new AA[idx+1];
  }

  loadcase[idx].grid_id = new int[nc];
  loadcase[idx].lv_x    = new double[nc];
  loadcase[idx].lv_y    = new double[nc];
  loadcase[idx].lv_z    = new double[nc];
idx and nc are passed in. Depending on the value of idx nc can hold different values. I am sure the way I am assigning memory to structure load is incorrect. But not sure how to increment it based on the value of idx.

Please help!