The SHA1() helper function was only used when calculating a
SHA1 hash and taking the first four bytes of it as uint32.
Make that explicit by renaming the function into SHA1_uint32()
and directly returning an uint32_t.
Note that the usage in cochran.cpp is sketchy: it generates
a four-byte hash out of two-byte data. Why!?
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Opportunistically fix some problems newly raised by a recent Coverity
scan.
Not touching any of the string memory allocation issues as this is being
handled by the move towards C++ strings.
Signed-off-by: Michael Keller <mikeller@042.ch>
This avoid memory-management troubles. Had to convert a few
of the parsers (cochran, datatrak, liquivision) to C++.
Also had to convert libdivecomputer.c. This was less
painful than expected.
std::string is used because parts of the code assumes
that the data is null terminated after the last character
of the data. std::string does precisely that.
One disadvantage is that std::string clears its memory
when resizing / initializing. Thus we read the file onto
freshly cleared data, which some might thing is a
performance regression. Until someone shows me that this
matters, I don't care.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>