This fixes a few code issues (bugs and some memory handling), plus bug-fixes for version 1.3 support by enforcing big-endian read and writes.
replaced CPPFLAGS and LDFLAGS for io_lib with io_lib-config
queries. This is gmake specific though and my code is still
relying on a fixed pathname for an io_lib installation.
I think "as is" this change isn't suitable, but I include it
for completeness and to demonstrate the official way to link
Force big-endian format, as per RQ-7. Previously the code
generated malformed SRF files on little-endian systems (eg
Intel/AMD based PCs).
Replaced ztrHeader with a std::string. I'm not sure that's the
optimal type for binary blobs of fata , but it works
The reason for this is that the ztr_t struct in memory isn't
necessarily the same layout as on disk. Furthermore the
headerBlob in DBH is not necessary just the ZTR header and it
may contain common chunks too. (In my solexa2srf code this is
exploited too to put common HUFF chunks there.)
Hence I treat it as a string and paste the two halves together
when decoding the ZTR file. This also means SRF_Read::populate
has an additional field for the header blob.
Fixed a memory leak. ztr is now deleted usign delete_ztr
instead which destroys the internal data structures as well as
the ztr malloced item itself.
Minor output formatting changes, including the trace data now
too. For testing/debugging purposes.
Fixed uninitialised memory accesses and rogue allocations.
Eof() only returns true when we've attempted to read *past*
the end of a stream and not when we are *at* the end. Hence it
always attempted to decode one chunk too many and due to lack
of checking that the initial read worked this meant it
malloced an arbitrary amount of data.
On my test machine it rapidly hit 510Gb of virtual memory -
fortunately only virtual :-)
I've also removed a memory leak by setting chunk->ztr_owns.
This is a new feature added to the recent io_lib releases to
allow data to be shared between multiple ztr creations (for
efficient caching of deflate_interlaced tables).
Replaced "delete foo" with "delete  foo" where foo had been
allocated via the pascal string functions using new .
Fixed bug in SRF_cStrToPascalStr where newStr needed to be one
longer (to hold the C nul char).
Allowed it to read a named file on the command line instead
of from stdin. This is purely my own preference to allow it to
be easily debugged via valgrind. So not an important change.
Also updated the newReadSet.setup() call to pass over a blank
string for the ztrHeader.