X-Git-Url: http://git.nguyen.vg/gitweb/?a=blobdiff_plain;f=BlockArray.h;h=1ee30c1c48825213b0b2b60f057c04f0a84642be;hb=338b9d601d0bae8ee76813852ea146ef7ba901d8;hp=3671d08cad25722bcebff65c5d98569af79aeb6f;hpb=b01061d44f36c8b6d2872202728869cd355e1f8d;p=SXSI%2FTextCollection.git diff --git a/BlockArray.h b/BlockArray.h index 3671d08..1ee30c1 100644 --- a/BlockArray.h +++ b/BlockArray.h @@ -60,11 +60,8 @@ public: if (std::fwrite(&(this->blockLength), sizeof(ulong), 1, file) != 1) throw std::runtime_error("BlockArray::Save(): file write error (blockLength)."); - for (ulong offset = 0; offset < n*blockLength/W+1; offset ++) - { - if (std::fwrite(this->data + offset, sizeof(ulong), 1, file) != 1) - throw std::runtime_error("BlockArray::Save(): file write error (data)."); - } + if (std::fwrite(this->data, sizeof(ulong), n*blockLength/W+1, file) != n*blockLength/W+1) + throw std::runtime_error("BlockArray::Save(): file write error (data)."); } /** @@ -78,11 +75,8 @@ public: throw std::runtime_error("BlockArray::Load(): file read error (blockLength)."); data = new ulong[n*blockLength/W+1]; - for (ulong offset = 0; offset < n*blockLength/W+1; offset ++) - { - if (std::fread(this->data + offset, sizeof(ulong), 1, file) != 1) - throw std::runtime_error("BlockArray::Load(): file read error (data)."); - } + if (std::fread(this->data, sizeof(ulong), n*blockLength/W+1, file) != n*blockLength/W+1) + throw std::runtime_error("BlockArray::Load(): file read error (data)."); } };