summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLibravatar Jeff King <peff@peff.net>2018-06-14 23:31:58 -0400
committerLibravatar Junio C Hamano <gitster@pobox.com>2018-06-18 10:16:19 -0700
commitcaa88140d4cc9e0ac79bb5d9d6569fe7d08a93a8 (patch)
treedfb22e23d78ee6d07a01e03ad054efe1cb9c6c75
parentewah_io: delete unused 'ewah_serialize()' (diff)
downloadtgif-caa88140d4cc9e0ac79bb5d9d6569fe7d08a93a8.tar.xz
ewah: drop ewah_deserialize function
We don't call this function, and in fact never have since it was added (at least not in iterations of the ewah patches that got merged). Instead we use ewah_read_mmap(). Let's drop the unused code. Note to anybody who later wants to resurrect this: it does not check for integer overflow in the ewah data size, meaning it may be possible to convince the code to allocate a too-small buffer and read() into it. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r--ewah/ewah_io.c55
-rw-r--r--ewah/ewok.h1
2 files changed, 0 insertions, 56 deletions
diff --git a/ewah/ewah_io.c b/ewah/ewah_io.c
index 345ee6287e..5e8fa9ebfc 100644
--- a/ewah/ewah_io.c
+++ b/ewah/ewah_io.c
@@ -158,58 +158,3 @@ ssize_t ewah_read_mmap(struct ewah_bitmap *self, const void *map, size_t len)
return ptr - (const uint8_t *)map;
}
-
-int ewah_deserialize(struct ewah_bitmap *self, int fd)
-{
- size_t i;
- eword_t dump[2048];
- const size_t words_per_dump = sizeof(dump) / sizeof(eword_t);
- uint32_t bitsize, word_count, rlw_pos;
-
- eword_t *buffer = NULL;
- size_t words_left;
-
- ewah_clear(self);
-
- /* 32 bit -- bit size for the map */
- if (read(fd, &bitsize, 4) != 4)
- return -1;
-
- self->bit_size = (size_t)ntohl(bitsize);
-
- /** 32 bit -- number of compressed 64-bit words */
- if (read(fd, &word_count, 4) != 4)
- return -1;
-
- self->buffer_size = self->alloc_size = (size_t)ntohl(word_count);
- REALLOC_ARRAY(self->buffer, self->alloc_size);
-
- /** 64 bit x N -- compressed words */
- buffer = self->buffer;
- words_left = self->buffer_size;
-
- while (words_left >= words_per_dump) {
- if (read(fd, dump, sizeof(dump)) != sizeof(dump))
- return -1;
-
- for (i = 0; i < words_per_dump; ++i, ++buffer)
- *buffer = ntohll(dump[i]);
-
- words_left -= words_per_dump;
- }
-
- if (words_left) {
- if (read(fd, dump, words_left * 8) != words_left * 8)
- return -1;
-
- for (i = 0; i < words_left; ++i, ++buffer)
- *buffer = ntohll(dump[i]);
- }
-
- /** 32 bit -- position for the RLW */
- if (read(fd, &rlw_pos, 4) != 4)
- return -1;
-
- self->rlw = self->buffer + ntohl(rlw_pos);
- return 0;
-}
diff --git a/ewah/ewok.h b/ewah/ewok.h
index 894f0dc5fd..e32a09cb27 100644
--- a/ewah/ewok.h
+++ b/ewah/ewok.h
@@ -89,7 +89,6 @@ int ewah_serialize_to(struct ewah_bitmap *self,
int ewah_serialize_native(struct ewah_bitmap *self, int fd);
int ewah_serialize_strbuf(struct ewah_bitmap *self, struct strbuf *);
-int ewah_deserialize(struct ewah_bitmap *self, int fd);
ssize_t ewah_read_mmap(struct ewah_bitmap *self, const void *map, size_t len);
uint32_t ewah_checksum(struct ewah_bitmap *self);