Public Methods | |
| void | KeepNewString (unsigned char *str, unsigned short len) |
Public Attributes | |
| CurRunLengthItem * | items |
| unsigned short | totallen |
| short | runlencount |
|
||||||||||||
|
Definition at line 70 of file RunLenCompress.cpp. 00074 {
00075 CurRunLengthItem **itemref;
00076 unsigned allocsize;
00077
00078 #ifdef XMILL
00079 runlencount=0;
00080 #endif
00081
00082 totallen=len;
00083
00084 itemref=&items;
00085
00086 // First, we copy the new string over the sequence of existing
00087 // CurRunLengthItem's
00088
00089 while(*itemref!=NULL)
00090 {
00091 (*itemref)->len = ((*itemref)->size < len) ? (*itemref)->size : len;
00092
00093 mymemcpy((*itemref)->GetStrPtr(),(char *)str,(*itemref)->len);
00094
00095 str+=(*itemref)->len;
00096 len-=(*itemref)->len;
00097
00098 itemref=&((*itemref)->next);
00099
00100 if(len==0) // Did we reach the end of new data?
00101 // (I.e. the new run length item is shorter)
00102 // We set the length of the remaining items to 0
00103 {
00104 while(*itemref!=NULL)
00105 {
00106 (*itemref)->len=0;
00107 itemref=&((*itemref)->next);
00108 }
00109 break;
00110 }
00111 }
00112
00113 if(len>0)
00114 // If there is still data left in the new run length string,
00115 // we need to allocate new memory for the remaining bytes
00116 {
00117 if(len<RUNLENGTH_ITEM_MINSIZE)
00118 allocsize=RUNLENGTH_ITEM_MINSIZE;
00119 else
00120 allocsize=((len-1)|3)+1;
00121
00122 *itemref=(CurRunLengthItem *)blockmem.GetByteBlock(sizeof(CurRunLengthItem)+allocsize);
00123
00124 (*itemref)->size=allocsize;
00125 (*itemref)->len=len;
00126
00127 mymemcpy((*itemref)->GetStrPtr(),(char *)str,len);
00128
00129 (*itemref)->next=NULL;
00130 }
00131 }
|
|
|
Definition at line 66 of file RunLenCompress.cpp. |
|
|
Definition at line 68 of file RunLenCompress.cpp. |
|
|
Definition at line 67 of file RunLenCompress.cpp. |
1.2.11.1 written by Dimitri van Heesch,
© 1997-2001