Revision 1598 trunk/src/nh99/model.cpp

model.cpp (revision 1598)
1234 1234

  
1235 1235

  
1236 1236
#if defined(__SPDLL__)
1237
#  if !defined(linux)
1238
#    include <windows.h>
1239
#  endif
1237
  #if defined(_WIN32)
1238
    #include <windows.h>
1240 1239
void get_sp_printf(void)
1241 1240
{
1242
#if !defined(linux)
1243 1241
  ad_printf=NULL;
1244 1242
  HINSTANCE h=LoadLibrary("sqpe.dll");
1245 1243
  if(h)
1246 1244
    ad_printf= (fptr) GetProcAddress(h,"S_newio_printf");
1247
#endif
1248 1245
}
1246
  #endif
1249 1247
#endif
1250 1248

  
1251
  pinitial_params & adlist_ptr::operator [] (int i)
1249
pinitial_params& adlist_ptr::operator[](int i)
1250
{
1251
  return (pinitial_params&)ptr[i];
1252
}
1253
/**
1254
Construct array with init_size.
1255
*/
1256
adlist_ptr::adlist_ptr(int init_size)
1257
{
1258
  current = 0;
1259
  ptr = new ptovoid[init_size];
1260
  if (ptr == 0)
1252 1261
  {
1253
    return (pinitial_params &) ptr[i];
1262
    cerr << "Error: allocating memory in adlist_ptr" << endl;
1254 1263
  }
1255

  
1256
  adlist_ptr::adlist_ptr(int init_size)
1264
  current_size = init_size;
1265
}
1266
void adlist_ptr::initialize()
1267
{
1268
  for (int i = 0; i < current_size; i++)
1257 1269
  {
1258
    current=0;
1259
    ptr = new ptovoid[init_size];
1260
    if (ptr==0)
1261
    {
1262
      cerr << "Errorl allocating memory in adlist_ptr" << endl;
1263
    }
1264
    current_size=init_size;
1270
    ptr[i] = 0;
1265 1271
  }
1266
  void adlist_ptr::resize(void)
1272
  //reset current index to beginning
1273
  current = 0;
1274
}
1275
/**
1276
Double array size if needed.
1277
*/
1278
void adlist_ptr::resize(void)
1279
{
1280
  current_size *= 2;
1281
  ptovoid* tmp = new ptovoid[current_size];
1282
  if (tmp == 0)
1267 1283
  {
1268
    current_size*=2;
1269
    ptovoid * tmp = new ptovoid[current_size];
1270
    if (tmp==0)
1271
    {
1272
      cerr << "Errorl allocating memory in adlist_ptr" << endl;
1273
    }
1274
    for (int i=0;i<current;i++)
1275
    {
1276
      tmp[i]=ptr[i];
1277
    }
1278
    delete [] ptr;
1279
    ptr = tmp;
1284
    cerr << "Error: allocating memory in adlist_ptr" << endl;
1280 1285
  }
1281
  void adlist_ptr::add_to_list(void * p)
1286
  for (int i=0;i<current;i++)
1282 1287
  {
1283
    if (current>current_size)
1284
    {
1285
      cerr << "This can't happen in adlist_ptr" << endl;
1286
      exit(1);
1287
    }
1288
    if (current==current_size)
1289
    {
1290
      resize();
1291
    }
1292
    ptr[current++]=p;
1288
    tmp[i] = ptr[i];
1293 1289
  }
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff