Revision 1181

branches/threaded2merge/src/nh99/admodel.h (revision 1181)
747 747
 */
748 748
class adlist_ptr
749 749
{
750
  ptovoid * ptr;
750
  ptovoid* ptr;
751 751
  int current_size;
752 752
  int current;
753 753
  void resize(void);
754 754
  void add_to_list(void * p);
755 755
public:
756
  adlist_ptr(int init_size);
756 757
  ~adlist_ptr();
757
  pinitial_params  & operator [] (int i);
758
  adlist_ptr(int init_size);
758
  pinitial_params& operator[](int i);
759
  void reinitialize();
760

  
759 761
  friend class initial_params;
760 762
};
761 763

  
branches/threaded2merge/src/nh99/model.cpp (revision 1181)
1230 1230
}
1231 1231
#endif
1232 1232

  
1233
  pinitial_params & adlist_ptr::operator [] (int i)
1233
pinitial_params& adlist_ptr::operator[](int i)
1234
{
1235
  return (pinitial_params&)ptr[i];
1236
}
1237
/**
1238
Constructor
1239
*/
1240
adlist_ptr::adlist_ptr(int init_size)
1241
{
1242
  current = 0;
1243
  ptr = new ptovoid[init_size];
1244
  if (ptr == 0)
1234 1245
  {
1235
    return (pinitial_params &) ptr[i];
1246
    cerr << "Error: allocating memory in adlist_ptr" << endl;
1247
    ad_exit(0);
1236 1248
  }
1237

  
1238
  adlist_ptr::adlist_ptr(int init_size)
1249
  current_size = init_size;
1250
  for (int i = 0; i < current_size; i++)
1239 1251
  {
1240
    current=0;
1241
    ptr = new ptovoid[init_size];
1242
    if (ptr==0)
1243
    {
1244
      cerr << "Errorl allocating memory in adlist_ptr" << endl;
1245
    }
1246
    current_size=init_size;
1252
    ptr[i] = 0;
1247 1253
  }
1248
  void adlist_ptr::resize(void)
1254
}
1255
/**
1256
*/
1257
void adlist_ptr::reinitialize()
1258
{
1259
  current = 0;
1260
  for (int i = 0; i < current_size; i++)
1249 1261
  {
1250
    current_size*=2;
1251
    ptovoid * tmp = new ptovoid[current_size];
1252
    if (tmp==0)
1253
    {
1254
      cerr << "Errorl allocating memory in adlist_ptr" << endl;
1255
    }
1256
    for (int i=0;i<current;i++)
1257
    {
1258
      tmp[i]=ptr[i];
1259
    }
1260
    delete [] ptr;
1261
    ptr = tmp;
1262
    ptr[i] = 0;
1262 1263
  }
1263
  void adlist_ptr::add_to_list(void * p)
1264
}
1265
/**
1266
Reallocate buffers.
1267
*/
1268
void adlist_ptr::resize(void)
1269
{
1270
  current_size *= 2;
1271
  ptovoid* tmp = new ptovoid[current_size];
1272
  if (tmp == 0)
1264 1273
  {
1265
    if (current>current_size)
1266
    {
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff