Rewrite hed_file_commit()
commit215fd62315de581b4aead96221547d106a534e61
authorPetr Tesarik <petr@tesarici.cz>
Fri, 2 Nov 2012 12:36:12 +0000 (2 13:36 +0100)
committerPetr Tesarik <petr@tesarici.cz>
Fri, 2 Nov 2012 12:36:12 +0000 (2 13:36 +0100)
tree731e1227e4e1804674b3a87f56eb1ec952e8feba
parent23194ba62dca7c7c8f8c64f8b6d87291b0961c2a
Rewrite hed_file_commit()

There old implementation was hard to maintain, because it iterated
over the logical blocks, updating struct commit_control after each
step. As a result, it needed up to THREE temporary buffers to handle
different forwards and backwards written chunks.

The new paradigm is different. Basically, it makes use of the existing
abstraction from the underlying block structure to split the logical
file into FILE_BLOCK_SIZE-sized chunks, which are then written to disk.

This reduces memory consumption (one buffer is always sufficient), and
also makes it easier to implement proper error handling (not done yet!).

Note that block-size granularity also applies to the last (partial) block
in the file, truncating the file afterwards. This can be an issue when
editing a file on a full device if the device block size is smaller than
hed's FILE_BLOCK_SIZE.
libhed/file.c