X-Git-Url: http://git.code-monkey.de/?a=blobdiff_plain;f=src%2Fpds.c;h=066666f13b6c402ac4c684e3e321907246d9b3a6;hb=97729daab63f49323ca6bee7859260653e5090a1;hp=0563c53653515d793c5be5c741809f8844bfb2b5;hpb=46d18f60766f997d0ca37c5937f58c0c06477932;p=umurmur.git diff --git a/src/pds.c b/src/pds.c index 0563c53..066666f 100644 --- a/src/pds.c +++ b/src/pds.c @@ -1,5 +1,5 @@ -/* Copyright (C) 2009-2010, Martin Johansson - Copyright (C) 2005-2010, Thorvald Natvig +/* Copyright (C) 2009-2014, Martin Johansson + Copyright (C) 2005-2014, Thorvald Natvig All rights reserved. @@ -95,14 +95,14 @@ uint8_t Pds_next8(pds_t *pds) int Pds_skip(pds_t *pds, int offset) { - if (pds->offset + offset < pds->maxsize) { + if (pds->offset + offset <= pds->maxsize) { pds->offset += offset; return offset; } else { pds->bOk = false; return 0; } - + } static inline uint64_t next(pds_t *pds) @@ -135,9 +135,9 @@ void Pds_free(pds_t *pds) void Pds_add_double(pds_t *pds, double value) { double64u_t u; - + u.dval = value; - + Pds_add_numval(pds, u.u64); } @@ -150,7 +150,7 @@ double Pds_get_double(pds_t *pds) void Pds_add_numval(pds_t *pds, const uint64_t value) { uint64_t i = value; - + if ((i & 0x8000000000000000LL) && (~i < 0x100000000LL)) { // Signed number. i = ~i; @@ -200,12 +200,12 @@ void Pds_add_numval(pds_t *pds, const uint64_t value) append_val(pds, i & 0xFF); } } - + uint64_t Pds_get_numval(pds_t *pds) { uint64_t i = 0; uint64_t v = next(pds); - + if ((v & 0x80) == 0x00) { i=(v & 0x7F); } else if ((v & 0xC0) == 0x80) {