Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 17, 2007, 8:23:26 PM (17 years ago)
Author:
scheusso
Message:

enhanced memory handling

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/FICN/src/network/GameStateManager.cc

    r573 r590  
    8282  //the size of the gamestate
    8383  int totalsize=0;
     84  int memsize=1000;
    8485  //the size of one specific synchronisable
    8586  int tempsize=0;
     
    9394  // reserve a little memory and increase it later on
    9495  COUT(2) << "mallocing" << std::endl;
    95   retval->data = (unsigned char*)malloc(1);
     96  retval->data = (unsigned char*)malloc(memsize);
    9697  COUT(2) << "malloced" << std::endl;
    9798
     
    106107    totalsize+=tempsize+3*sizeof(int);
    107108    // allocate additional space
    108     retval->data = (unsigned char *)realloc((void *)retval->data, totalsize);
     109    if(totalsize+tempsize>memsize){
     110      retval->data = (unsigned char *)realloc((void *)retval->data, totalsize+1000);
     111      memsize+=1000;
     112    }
    109113
    110114    // run Synchronisable::getData with offset and additional place for 3 ints in between (for ids and length)
Note: See TracChangeset for help on using the changeset viewer.