Fixed bugs in compaction.

- Added new Reset() method in the resource manager, so that all
  attributes can be reset before each compaction process. This wasn't
  done, and compactions would still carry the data of the previous ones
  and introduce mistakes in the index.
- Added calls to ftruncate() so that the files would be truncated to the
  right sizes after compaction, and get rid of all non-needed space left
  by the pre-allocation.