From 41a7566c121a865b460649390a75473ac71eff1f Mon Sep 17 00:00:00 2001 From: jakob Date: Sun, 14 May 2017 11:20:43 -0400 Subject: Fixed issue with dump_table --- src/table.c | 5 +++-- src/table.h | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/table.c b/src/table.c index 7bf6c2a..849780d 100644 --- a/src/table.c +++ b/src/table.c @@ -243,7 +243,8 @@ static void dump_segm(struct stream *s, struct table_entry *cur) { /* Dumps the File entry for `cur` into the table at `s` and returns the number of bytes written. */ static uint64_t dump_file(struct stream *s, struct table_entry *cur) { - uint32_t magic = FILE_MAGIC; + uint32_t magic = FILE_MAGIC; + uint64_t bytes_written = 28 * cur->segment_count + 48; stream_write(s, &magic, sizeof(uint32_t)); stream_write(s, &bytes_written, sizeof(uint64_t)); @@ -254,7 +255,7 @@ static uint64_t dump_file(struct stream *s, struct table_entry *cur) { stream_seek(s, -bytes_written, SEEK_CUR); stream_write(s, &bytes_written, sizeof(uint64_t)); stream_seek(s, bytes_written, SEEK_CUR); - return 28 * cur->segment_count + 48; + return bytes_written; } diff --git a/src/table.h b/src/table.h index 53012f7..e36759c 100644 --- a/src/table.h +++ b/src/table.h @@ -76,7 +76,7 @@ void entry_free(struct table_entry *cur); /* Dumps the XP3 table specified by `root` into `s` and returns the number of bytes written. */ -void dump_table(struct stream *s, struct table_entry *root); +uint64_t dump_table(struct stream *s, struct table_entry *root); /* Inserts the file specified by `path` into the table linked list specified by `root`. */ -- cgit v1.3