00073 {
00074 UnpackDataBlock *firstdatablock=NULL,**lastdatablockref=&firstdatablock;
00075
00076 while(lastblock->used+sizeof(UnpackDataBlock)+len>lastblock->len)
00077
00078
00079 {
00080 if(lastblock->used+sizeof(UnpackDataBlock)+MIN_DATABLOCKSIZE<lastblock->len)
00081
00082
00083 {
00084 *lastdatablockref=(UnpackDataBlock *)((char *)(lastblock+1)+lastblock->used);
00085 (*lastdatablockref)->len=lastblock->len-lastblock->used-sizeof(UnpackDataBlock);
00086 (*lastdatablockref)->next=NULL;
00087
00088 len-=(*lastdatablockref)->len;
00089 neededmemoryspace-=(*lastdatablockref)->len;
00090
00091 lastblock->used=lastblock->len;
00092
00093 lastdatablockref=&((*lastdatablockref)->next);
00094 }
00095
00096
00097
00098 lastblock=AllocateMemBlock(&(lastblock->next));
00099 if(lastblock==NULL)
00100 return NULL;
00101
00102 lastblock=lastblock->next;
00103 }
00104
00105 *lastdatablockref=(UnpackDataBlock *)((char *)(lastblock+1)+lastblock->used);
00106 (*lastdatablockref)->len=len;
00107 (*lastdatablockref)->next=NULL;
00108
00109 neededmemoryspace-=len+sizeof(UnpackDataBlock);
00110
00111 lastblock->used+=sizeof(UnpackDataBlock)+len;
00112
00113 return firstdatablock;
00114 }