Skip to content

Commit caa8814

Browse files
peffgitster
authored andcommitted
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>
1 parent 83ea4e1 commit caa8814

File tree

2 files changed

+0
-56
lines changed

2 files changed

+0
-56
lines changed

ewah/ewah_io.c

Lines changed: 0 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -158,58 +158,3 @@ ssize_t ewah_read_mmap(struct ewah_bitmap *self, const void *map, size_t len)
158158

159159
return ptr - (const uint8_t *)map;
160160
}
161-
162-
int ewah_deserialize(struct ewah_bitmap *self, int fd)
163-
{
164-
size_t i;
165-
eword_t dump[2048];
166-
const size_t words_per_dump = sizeof(dump) / sizeof(eword_t);
167-
uint32_t bitsize, word_count, rlw_pos;
168-
169-
eword_t *buffer = NULL;
170-
size_t words_left;
171-
172-
ewah_clear(self);
173-
174-
/* 32 bit -- bit size for the map */
175-
if (read(fd, &bitsize, 4) != 4)
176-
return -1;
177-
178-
self->bit_size = (size_t)ntohl(bitsize);
179-
180-
/** 32 bit -- number of compressed 64-bit words */
181-
if (read(fd, &word_count, 4) != 4)
182-
return -1;
183-
184-
self->buffer_size = self->alloc_size = (size_t)ntohl(word_count);
185-
REALLOC_ARRAY(self->buffer, self->alloc_size);
186-
187-
/** 64 bit x N -- compressed words */
188-
buffer = self->buffer;
189-
words_left = self->buffer_size;
190-
191-
while (words_left >= words_per_dump) {
192-
if (read(fd, dump, sizeof(dump)) != sizeof(dump))
193-
return -1;
194-
195-
for (i = 0; i < words_per_dump; ++i, ++buffer)
196-
*buffer = ntohll(dump[i]);
197-
198-
words_left -= words_per_dump;
199-
}
200-
201-
if (words_left) {
202-
if (read(fd, dump, words_left * 8) != words_left * 8)
203-
return -1;
204-
205-
for (i = 0; i < words_left; ++i, ++buffer)
206-
*buffer = ntohll(dump[i]);
207-
}
208-
209-
/** 32 bit -- position for the RLW */
210-
if (read(fd, &rlw_pos, 4) != 4)
211-
return -1;
212-
213-
self->rlw = self->buffer + ntohl(rlw_pos);
214-
return 0;
215-
}

ewah/ewok.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@ int ewah_serialize_to(struct ewah_bitmap *self,
8989
int ewah_serialize_native(struct ewah_bitmap *self, int fd);
9090
int ewah_serialize_strbuf(struct ewah_bitmap *self, struct strbuf *);
9191

92-
int ewah_deserialize(struct ewah_bitmap *self, int fd);
9392
ssize_t ewah_read_mmap(struct ewah_bitmap *self, const void *map, size_t len);
9493

9594
uint32_t ewah_checksum(struct ewah_bitmap *self);

0 commit comments

Comments
 (0)