| 1 |
Index: b/htword/WordBitCompress.cc |
| 2 |
=================================================================== |
| 3 |
--- a/htword/WordBitCompress.cc |
| 4 |
+++ b/htword/WordBitCompress.cc |
| 5 |
@@ -29,7 +29,7 @@ |
| 6 |
#include"WordBitCompress.h" |
| 7 |
|
| 8 |
// ******** HtVector_byte (implementation) |
| 9 |
-#define GType byte |
| 10 |
+#define GType byte_t |
| 11 |
#define HtVectorGType HtVector_byte |
| 12 |
#include "HtVectorGenericCode.h" |
| 13 |
|
| 14 |
@@ -424,13 +424,13 @@ |
| 15 |
// ************************************************** |
| 16 |
|
| 17 |
void |
| 18 |
-BitStream::put_zone(byte *vals,int n,const char *tag) |
| 19 |
+BitStream::put_zone(byte_t *vals,int n,const char *tag) |
| 20 |
{ |
| 21 |
add_tag(tag); |
| 22 |
for(int i=0;i<(n+7)/8;i++){put_uint(vals[i],TMin(8,n-8*i),NULL);} |
| 23 |
} |
| 24 |
void |
| 25 |
-BitStream::get_zone(byte *vals,int n,const char *tag) |
| 26 |
+BitStream::get_zone(byte_t *vals,int n,const char *tag) |
| 27 |
{ |
| 28 |
check_tag(tag); |
| 29 |
for(int i=0;i<(n+7)/8;i++){vals[i]=get_uint(TMin(8,n-8*i));} |
| 30 |
@@ -699,16 +699,16 @@ |
| 31 |
if(all){printf("\n");} |
| 32 |
|
| 33 |
} |
| 34 |
-byte * |
| 35 |
+byte_t * |
| 36 |
BitStream::get_data() |
| 37 |
{ |
| 38 |
- byte *res=(byte *)malloc(buff.size()); |
| 39 |
+ byte_t *res=(byte_t *)malloc(buff.size()); |
| 40 |
CHECK_MEM(res); |
| 41 |
for(int i=0;i<buff.size();i++){res[i]=buff[i];} |
| 42 |
return(res); |
| 43 |
} |
| 44 |
void |
| 45 |
-BitStream::set_data(const byte *nbuff,int nbits) |
| 46 |
+BitStream::set_data(const byte_t *nbuff,int nbits) |
| 47 |
{ |
| 48 |
if(buff.size()!=1 || bitpos!=0) |
| 49 |
{ |
| 50 |
@@ -835,7 +835,7 @@ |
| 51 |
|
| 52 |
|
| 53 |
int |
| 54 |
-Compressor::put_fixedbitl(byte *vals,int n,const char *tag) |
| 55 |
+Compressor::put_fixedbitl(byte_t *vals,int n,const char *tag) |
| 56 |
{ |
| 57 |
int cpos=bitpos; |
| 58 |
int i,j; |
| 59 |
@@ -844,19 +844,19 @@ |
| 60 |
put_uint_vl(n,NBITS_NVALS,"size"); |
| 61 |
if(n==0){return 0;} |
| 62 |
|
| 63 |
- byte maxv=vals[0]; |
| 64 |
+ byte_t maxv=vals[0]; |
| 65 |
for(i=1;i<n;i++) |
| 66 |
{ |
| 67 |
- byte v=vals[i]; |
| 68 |
+ byte_t v=vals[i]; |
| 69 |
if(v>maxv){maxv=v;} |
| 70 |
} |
| 71 |
int nbits=num_bits(maxv); |
| 72 |
- if(n>=pow2(NBITS_NVALS)){errr("Compressor::put_fixedbitl(byte *) : overflow: nvals>2^16");} |
| 73 |
+ if(n>=pow2(NBITS_NVALS)){errr("Compressor::put_fixedbitl(byte_t *) : overflow: nvals>2^16");} |
| 74 |
put_uint(nbits,NBITS_NBITS_CHARVAL,"nbits"); |
| 75 |
add_tag("data"); |
| 76 |
for(i=0;i<n;i++) |
| 77 |
{ |
| 78 |
- byte v=vals[i]; |
| 79 |
+ byte_t v=vals[i]; |
| 80 |
for(j=0;j<nbits;j++) {put(v&pow2(j));} |
| 81 |
} |
| 82 |
return(bitpos-cpos); |
| 83 |
@@ -887,15 +887,15 @@ |
| 84 |
} |
| 85 |
} |
| 86 |
int |
| 87 |
-Compressor::get_fixedbitl(byte **pres,const char *tag/*="BADTAG!"*/) |
| 88 |
+Compressor::get_fixedbitl(byte_t **pres,const char *tag/*="BADTAG!"*/) |
| 89 |
{ |
| 90 |
- if(check_tag(tag)==NOTOK){errr("Compressor::get_fixedbitl(byte *): check_tag failed");} |
| 91 |
+ if(check_tag(tag)==NOTOK){errr("Compressor::get_fixedbitl(byte_t *): check_tag failed");} |
| 92 |
int n=get_uint_vl(NBITS_NVALS); |
| 93 |
if(!n){*pres=NULL;return 0;} |
| 94 |
int nbits=get_uint(NBITS_NBITS_CHARVAL); |
| 95 |
- if(verbose)printf("get_fixedbitl(byte):n%3d nbits:%2d\n",n,nbits); |
| 96 |
+ if(verbose)printf("get_fixedbitl(byte_t):n%3d nbits:%2d\n",n,nbits); |
| 97 |
int i; |
| 98 |
- byte *res=new byte[n]; |
| 99 |
+ byte_t *res=new byte_t[n]; |
| 100 |
CHECK_MEM(res); |
| 101 |
for(i=0;i<n;i++) |
| 102 |
{ |
| 103 |
Index: b/htword/WordBitCompress.h |
| 104 |
=================================================================== |
| 105 |
--- a/htword/WordBitCompress.h |
| 106 |
+++ b/htword/WordBitCompress.h |
| 107 |
@@ -28,9 +28,9 @@ |
| 108 |
#include"HtVector_int.h" |
| 109 |
#include"HtMaxMin.h" |
| 110 |
|
| 111 |
-typedef unsigned char byte; |
| 112 |
+typedef unsigned char byte_t; |
| 113 |
// ******** HtVector_byte (header) |
| 114 |
-#define GType byte |
| 115 |
+#define GType byte_t |
| 116 |
#define HtVectorGType HtVector_byte |
| 117 |
#include "HtVectorGeneric.h" |
| 118 |
|
| 119 |
@@ -123,12 +123,12 @@ |
| 120 |
} |
| 121 |
|
| 122 |
// gets a bit from the bitstream |
| 123 |
- inline byte get(const char *tag=(char*)NULL) |
| 124 |
+ inline byte_t get(const char *tag=(char*)NULL) |
| 125 |
{ |
| 126 |
// SPEED CRITICAL SECTION |
| 127 |
if(check_tag(tag)==NOTOK){errr("BitStream::get() check_tag failed");} |
| 128 |
if(bitpos>=(buff.size()<<3)){errr("BitStream::get reading past end of BitStream!");} |
| 129 |
- byte res=buff[bitpos>>3] & pow2(bitpos & 0x07); |
| 130 |
+ byte_t res=buff[bitpos>>3] & pow2(bitpos & 0x07); |
| 131 |
// printf("get:res:%d bitpos:%5d/%d buff[%3d]=%x\n",res,bitpos,bitpos%8,bitpos/8,buff[bitpos/8]); |
| 132 |
bitpos++; |
| 133 |
return(res); |
| 134 |
@@ -139,8 +139,8 @@ |
| 135 |
unsigned int get_uint( int n,const char *tag=(char*)NULL); |
| 136 |
|
| 137 |
// get/put n bits of data stored in vals |
| 138 |
- void put_zone(byte *vals,int n,const char *tag); |
| 139 |
- void get_zone(byte *vals,int n,const char *tag); |
| 140 |
+ void put_zone(byte_t *vals,int n,const char *tag); |
| 141 |
+ void get_zone(byte_t *vals,int n,const char *tag); |
| 142 |
|
| 143 |
// |
| 144 |
inline void add_tag(const char *tag) |
| 145 |
@@ -167,9 +167,9 @@ |
| 146 |
int buffsize(){return(buff.size());} |
| 147 |
|
| 148 |
// get a copy of the buffer |
| 149 |
- byte *get_data(); |
| 150 |
+ byte_t *get_data(); |
| 151 |
// set the buffer from outside data (current buffer must be empty) |
| 152 |
- void set_data(const byte *nbuff,int nbits); |
| 153 |
+ void set_data(const byte_t *nbuff,int nbits); |
| 154 |
|
| 155 |
// use this for reading a BitStream after you have written in it |
| 156 |
// (generally for debuging) |
| 157 |
@@ -211,7 +211,7 @@ |
| 158 |
#define NBITS_VAL 32 |
| 159 |
// number of bits to code he number of bits used by an unsigned int value |
| 160 |
#define NBITS_NBITS_VAL 5 |
| 161 |
-// number of bits to code the number of bits used by a byte value |
| 162 |
+// number of bits to code the number of bits used by a byte_t value |
| 163 |
#define NBITS_NBITS_CHARVAL 4 |
| 164 |
|
| 165 |
class Compressor : public BitStream |
| 166 |
@@ -240,8 +240,8 @@ |
| 167 |
int get_vals(unsigned int **pres,const char *tag=(char*)"BADTAG!"); |
| 168 |
|
| 169 |
// compress/decompress an array of bytes (very simple) |
| 170 |
- int put_fixedbitl(byte *vals,int n,const char *tag); |
| 171 |
- int get_fixedbitl(byte **pres,const char *tag=(char*)"BADTAG!"); |
| 172 |
+ int put_fixedbitl(byte_t *vals,int n,const char *tag); |
| 173 |
+ int get_fixedbitl(byte_t **pres,const char *tag=(char*)"BADTAG!"); |
| 174 |
|
| 175 |
// compress/decompress an array of unsigned ints (very simple) |
| 176 |
void get_fixedbitl(unsigned int *res,int n); |
| 177 |
Index: b/htword/WordDBPage.cc |
| 178 |
=================================================================== |
| 179 |
--- a/htword/WordDBPage.cc |
| 180 |
+++ b/htword/WordDBPage.cc |
| 181 |
@@ -155,7 +155,7 @@ |
| 182 |
Uncompress_main(pin); |
| 183 |
break; |
| 184 |
case CMPRTYPE_BADCOMPRESS:// this page did not compress correctly |
| 185 |
- pin->get_zone((byte *)pg,pgsz*8,"INITIALBUFFER"); |
| 186 |
+ pin->get_zone((byte_t *)pg,pgsz*8,"INITIALBUFFER"); |
| 187 |
break; |
| 188 |
default: |
| 189 |
errr("WordDBPage::Uncompress: CMPRTYPE incoherent"); |
| 190 |
@@ -181,7 +181,7 @@ |
| 191 |
int *rnum_sizes=new int[nnums]; |
| 192 |
CHECK_MEM(rnum_sizes); |
| 193 |
// char differences between words |
| 194 |
- byte *rworddiffs=NULL; |
| 195 |
+ byte_t *rworddiffs=NULL; |
| 196 |
int nrworddiffs; |
| 197 |
|
| 198 |
// *********** read header |
| 199 |
@@ -288,7 +288,7 @@ |
| 200 |
return OK; |
| 201 |
} |
| 202 |
void |
| 203 |
-WordDBPage::Uncompress_rebuild(unsigned int **rnums,int *rnum_sizes,int nnums0,byte *rworddiffs,int nrworddiffs) |
| 204 |
+WordDBPage::Uncompress_rebuild(unsigned int **rnums,int *rnum_sizes,int nnums0,byte_t *rworddiffs,int nrworddiffs) |
| 205 |
{ |
| 206 |
int irwordiffs=0; |
| 207 |
int nfields=WordKey::NFields(); |
| 208 |
@@ -405,7 +405,7 @@ |
| 209 |
|
| 210 |
// display |
| 211 |
void |
| 212 |
-WordDBPage::Uncompress_show_rebuild(unsigned int **rnums,int *rnum_sizes,int nnums0,byte *rworddiffs,int nrworddiffs) |
| 213 |
+WordDBPage::Uncompress_show_rebuild(unsigned int **rnums,int *rnum_sizes,int nnums0,byte_t *rworddiffs,int nrworddiffs) |
| 214 |
{ |
| 215 |
int i,j; |
| 216 |
if(verbose) |
| 217 |
@@ -464,7 +464,7 @@ |
| 218 |
res->put_uint(COMPRESS_VERSION,NBITS_COMPRESS_VERSION,"COMPRESS_VERSION"); |
| 219 |
res->put_uint(CMPRTYPE_BADCOMPRESS,NBITS_CMPRTYPE,"CMPRTYPE"); |
| 220 |
|
| 221 |
- res->put_zone((byte *)pg,pgsz*8,"INITIALBUFFER"); |
| 222 |
+ res->put_zone((byte_t *)pg,pgsz*8,"INITIALBUFFER"); |
| 223 |
} |
| 224 |
|
| 225 |
if(verbose) |
| 226 |
@@ -761,7 +761,7 @@ |
| 227 |
printf("compare failed in some unknown place in header:\n"); |
| 228 |
for(i=0;i<(int)(sizeof(PAGE)-sizeof(db_indx_t));i++) |
| 229 |
{ |
| 230 |
- printf("%3d: %3x %3x\n",i,((byte *)pg)[i],((byte *)other.pg)[i]); |
| 231 |
+ printf("%3d: %3x %3x\n",i,((byte_t *)pg)[i],((byte_t *)other.pg)[i]); |
| 232 |
} |
| 233 |
} |
| 234 |
|
| 235 |
@@ -998,7 +998,7 @@ |
| 236 |
printf("%5d: ",nn); |
| 237 |
for(j=0;j<20;j++) |
| 238 |
{ |
| 239 |
- printf("%2x ",((byte *)pg)[nn++]); |
| 240 |
+ printf("%2x ",((byte_t *)pg)[nn++]); |
| 241 |
if(nn>=pgsz){break;} |
| 242 |
} |
| 243 |
printf("\n"); |
| 244 |
Index: b/htword/WordDBPage.h |
| 245 |
=================================================================== |
| 246 |
--- a/htword/WordDBPage.h |
| 247 |
+++ b/htword/WordDBPage.h |
| 248 |
@@ -65,7 +65,7 @@ |
| 249 |
} |
| 250 |
} |
| 251 |
WordDBRecord():WordRecord(){;} |
| 252 |
- WordDBRecord(byte *dat,int len,int rectyp):WordRecord() |
| 253 |
+ WordDBRecord(byte_t *dat,int len,int rectyp):WordRecord() |
| 254 |
{ |
| 255 |
type=(rectyp ? DefaultType() : WORD_RECORD_STATS); |
| 256 |
Unpack(String((char *)dat,len)); |
| 257 |
@@ -118,7 +118,7 @@ |
| 258 |
} |
| 259 |
else{Unpack(String((char *)nkey->data,nkey->len));} |
| 260 |
} |
| 261 |
- WordDBKey(byte *data,int len):WordKey() |
| 262 |
+ WordDBKey(byte_t *data,int len):WordKey() |
| 263 |
{ |
| 264 |
key=NULL; |
| 265 |
if(!data || !len){errr("WordDBKey::WordDBKey(data,len) !data || !len");} |
| 266 |
@@ -207,7 +207,7 @@ |
| 267 |
void *alloc_entry(int size) |
| 268 |
{ |
| 269 |
size=WORD_ALIGN_TO(size,4); |
| 270 |
- int inp_pos=((byte *)&(pg->inp[insert_indx]))-(byte *)pg; |
| 271 |
+ int inp_pos=((byte_t *)&(pg->inp[insert_indx]))-(byte_t *)pg; |
| 272 |
insert_pos-=size; |
| 273 |
if(insert_pos<=inp_pos) |
| 274 |
{ |
| 275 |
@@ -216,7 +216,7 @@ |
| 276 |
errr("WordDBPage::alloc_entry: PAGE OVERFLOW"); |
| 277 |
} |
| 278 |
pg->inp[insert_indx++]=insert_pos; |
| 279 |
- return((void *)((byte *)pg+insert_pos)); |
| 280 |
+ return((void *)((byte_t *)pg+insert_pos)); |
| 281 |
} |
| 282 |
|
| 283 |
|
| 284 |
@@ -260,11 +260,11 @@ |
| 285 |
ky.Pack(pkey); |
| 286 |
keylen=pkey.length(); |
| 287 |
} |
| 288 |
- int size=keylen+((byte *)&(bti.data))-((byte *)&bti);// pos of data field in BINTERNAL |
| 289 |
+ int size=keylen+((byte_t *)&(bti.data))-((byte_t *)&bti);// pos of data field in BINTERNAL |
| 290 |
if(empty) |
| 291 |
{ |
| 292 |
if(verbose){printf("WordDBPage::insert_btikey: empty : BINTERNAL:%d datapos:%d keylen:%d size:%d alligned to:%d\n",(int)sizeof(BINTERNAL), |
| 293 |
- (int)(((byte *)&(bti.data))-((byte *)&bti)), |
| 294 |
+ (int)(((byte_t *)&(bti.data))-((byte_t *)&bti)), |
| 295 |
keylen,size,WORD_ALIGN_TO(size,4));} |
| 296 |
} |
| 297 |
|
| 298 |
@@ -306,8 +306,8 @@ |
| 299 |
int Uncompress_main(Compressor *pin); |
| 300 |
void Uncompress_vals_chaged_flags(Compressor &in,unsigned int **pcflags,int *pn); |
| 301 |
int Uncompress_header(Compressor &in); |
| 302 |
- void Uncompress_rebuild(unsigned int **rnums,int *rnum_sizes,int nnums,byte *rworddiffs,int nrworddiffs); |
| 303 |
- void Uncompress_show_rebuild(unsigned int **rnums,int *rnum_sizes,int nnums,byte *rworddiffs,int nrworddiffs); |
| 304 |
+ void Uncompress_rebuild(unsigned int **rnums,int *rnum_sizes,int nnums,byte_t *rworddiffs,int nrworddiffs); |
| 305 |
+ void Uncompress_show_rebuild(unsigned int **rnums,int *rnum_sizes,int nnums,byte_t *rworddiffs,int nrworddiffs); |
| 306 |
|
| 307 |
int TestCompress(int debuglevel); |
| 308 |
int Compare(WordDBPage &other); |
| 309 |
@@ -326,14 +326,14 @@ |
| 310 |
out.put_uint(btikey(i)->type ,sizeof(btikey(i)->type )*8,label_str("seperatekey_bti_type" ,i)); |
| 311 |
out.put_uint(btikey(i)->pgno ,sizeof(btikey(i)->pgno )*8,label_str("seperatekey_bti_pgno" ,i)); |
| 312 |
out.put_uint(btikey(i)->nrecs,sizeof(btikey(i)->nrecs)*8,label_str("seperatekey_bti_nrecs",i)); |
| 313 |
- if(len){out.put_zone((byte *)btikey(i)->data,8*len,label_str("seperatekey_btidata",i));} |
| 314 |
+ if(len){out.put_zone((byte_t *)btikey(i)->data,8*len,label_str("seperatekey_btidata",i));} |
| 315 |
} |
| 316 |
else |
| 317 |
{ |
| 318 |
int len=key(i)->len; |
| 319 |
out.put_uint(len,NBITS_KEYLEN,label_str("seperatekey_len",i)); |
| 320 |
if(verbose){printf("WordDBPage::compress_key: compress(typ5):%d\n",len);} |
| 321 |
- out.put_zone((byte *)key(i)->data,8*len,label_str("seperatekey_data",i)); |
| 322 |
+ out.put_zone((byte_t *)key(i)->data,8*len,label_str("seperatekey_data",i)); |
| 323 |
} |
| 324 |
} |
| 325 |
void compress_data(Compressor &out,int i) |
| 326 |
@@ -341,7 +341,7 @@ |
| 327 |
int len=data(i)->len; |
| 328 |
out.put_uint(len,NBITS_DATALEN,label_str("seperatedata_len",i)); |
| 329 |
if(verbose){printf("WordDBPage::compress_data: compressdata(typ5):%d\n",len);} |
| 330 |
- out.put_zone((byte *)data(i)->data,8*len,label_str("seperatedata_data",i)); |
| 331 |
+ out.put_zone((byte_t *)data(i)->data,8*len,label_str("seperatedata_data",i)); |
| 332 |
} |
| 333 |
WordDBKey uncompress_key(Compressor &in,int i) |
| 334 |
{ |
| 335 |
@@ -360,7 +360,7 @@ |
| 336 |
if(len!=bti.len){errr("WordDBPage::uncompress_key: incoherence: len!=bti.len");} |
| 337 |
if(len) |
| 338 |
{ |
| 339 |
- byte *gotdata=new byte[len]; |
| 340 |
+ byte_t *gotdata=new byte_t[len]; |
| 341 |
CHECK_MEM(gotdata); |
| 342 |
in.get_zone(gotdata,8*len,label_str("seperatekey_btidata",i)); |
| 343 |
res=WordDBKey(gotdata,len); |
| 344 |
@@ -370,7 +370,7 @@ |
| 345 |
} |
| 346 |
else |
| 347 |
{ |
| 348 |
- byte *gotdata=new byte[len]; |
| 349 |
+ byte_t *gotdata=new byte_t[len]; |
| 350 |
CHECK_MEM(gotdata); |
| 351 |
in.get_zone(gotdata,8*len,label_str("seperatekey_data",i)); |
| 352 |
res=WordDBKey(gotdata,len); |
| 353 |
@@ -384,7 +384,7 @@ |
| 354 |
WordDBRecord res; |
| 355 |
int len=in.get_uint(NBITS_DATALEN,label_str("seperatedata_len",i)); |
| 356 |
if(verbose)printf("uncompressdata:len:%d\n",len); |
| 357 |
- byte *gotdata=new byte[len]; |
| 358 |
+ byte_t *gotdata=new byte_t[len]; |
| 359 |
CHECK_MEM(gotdata); |
| 360 |
in.get_zone(gotdata,8*len,label_str("seperatedata_data",i)); |
| 361 |
res=WordDBRecord(gotdata,len,rectyp); |
| 362 |
@@ -488,7 +488,7 @@ |
| 363 |
{ |
| 364 |
init0(); |
| 365 |
pgsz=npgsz; |
| 366 |
- pg=(PAGE *)(new byte[pgsz]); |
| 367 |
+ pg=(PAGE *)(new byte_t[pgsz]); |
| 368 |
CHECK_MEM(pg); |
| 369 |
insert_pos=pgsz; |
| 370 |
insert_indx=0; |