Skip to content

Commit bc0d966

Browse files
committed
Fix OSX conversion issues
1 parent 2dc7ec1 commit bc0d966

2 files changed

Lines changed: 17 additions & 4 deletions

File tree

libhdt/src/libdcs/CSD_PFC.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,11 @@ size_t CSD_PFC::load(unsigned char *ptr, unsigned char *ptrMax) {
302302
if(ptr[count++] != PFC)
303303
throw std::runtime_error("Trying to read a CSD_PFC but type does not match");
304304

305-
count += VByte::decode(&ptr[count], ptrMax, &numstrings);
305+
if(sizeof(numstrings) == 8)
306+
count += VByte::decode(&ptr[count], ptrMax, (uint64_t*) &numstrings);
307+
else
308+
count += VByte::decode(&ptr[count], ptrMax, (uint32_t*) &numstrings);
309+
306310
count += VByte::decode(&ptr[count], ptrMax, &bytes);
307311
count += VByte::decode(&ptr[count], ptrMax, &blocksize);
308312

@@ -541,7 +545,10 @@ void CSD_PFC::fillSuggestions(const char *base, vector<std::string> &out, int ma
541545
while ( (idInBlock<blocksize) && (pos<bytes) && !terminate)
542546
{
543547
// Decode the prefix
544-
pos += VByte::decode(text+pos, text+bytes, &delta);
548+
if(sizeof(delta) == 8)
549+
pos += VByte::decode(text+pos, text+bytes, (uint64_t*) &delta);
550+
else
551+
pos += VByte::decode(text+pos, text+bytes, (uint32_t*) &delta);
545552

546553
// Guess suffix size
547554
slen = strlen((char*)text+pos)+1;

libhdt/src/libdcs/CSD_PFC.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,10 @@ class PFCSuggestionIterator: public hdt::IteratorUCharString {
261261

262262
while (((idInBlock < pfc->blocksize) && (pos < pfc->bytes) && !terminate) && !hasNext()) {
263263
// Decode the prefix
264-
pos += VByte::decode(pfc->text + pos, pfc->text + pfc->bytes, &delta);
264+
if(sizeof(delta) == 8)
265+
pos += VByte::decode(pfc->text + pos, pfc->text + pfc->bytes, (uint64_t*) &delta);
266+
else
267+
pos += VByte::decode(pfc->text + pos, pfc->text + pfc->bytes, (uint32_t*) &delta);
265268

266269
// Guess suffix size
267270
slen = strlen((char*) pfc->text + pos) + 1;
@@ -395,7 +398,10 @@ class PFCSuggestionIDIterator: public hdt::IteratorUInt {
395398

396399
while (((idInBlock < pfc->blocksize) && (pos < pfc->bytes) && !terminate) && !hasNext()) {
397400
// Decode the prefix
398-
pos += VByte::decode(pfc->text + pos, pfc->text + pfc->bytes, &delta);
401+
if(sizeof(delta) == 8)
402+
pos += VByte::decode(pfc->text + pos, pfc->text + pfc->bytes, (uint64_t*) &delta);
403+
else
404+
pos += VByte::decode(pfc->text + pos, pfc->text + pfc->bytes, (uint32_t*) &delta);
399405

400406
// Guess suffix size
401407
slen = strlen((char*) pfc->text + pos) + 1;

0 commit comments

Comments
 (0)