From dff2bd733fc2dac08d34f2cfad0e68aeb8e7a7a2 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Fri, 24 May 2019 17:03:28 +0200 Subject: libarchive: treat one "FIXME: avoid seek" function old new delta xmalloc_read_with_initial_buf - 205 +205 setup_transformer_on_fd 154 150 -4 xmalloc_open_zipped_read_close 143 135 -8 xmalloc_read 201 10 -191 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 0/3 up/down: 205/-203) Total: 2 bytes Signed-off-by: Denys Vlasenko --- include/bb_archive.h | 6 ++++++ include/libbb.h | 1 + 2 files changed, 7 insertions(+) (limited to 'include') diff --git a/include/bb_archive.h b/include/bb_archive.h index 561dd0c9d..9b1db5b3e 100644 --- a/include/bb_archive.h +++ b/include/bb_archive.h @@ -235,6 +235,12 @@ typedef struct transformer_state_t { off_t bytes_in; /* used in unzip code only: needs to know packed size */ uint32_t crc32; time_t mtime; /* gunzip code may set this on exit */ + + union { /* if we read magic, it's saved here */ + uint8_t b[8]; + uint16_t b16[4]; + uint32_t b32[2]; + } magic; } transformer_state_t; void init_transformer_state(transformer_state_t *xstate) FAST_FUNC; diff --git a/include/libbb.h b/include/libbb.h index 57cfce385..33766e989 100644 --- a/include/libbb.h +++ b/include/libbb.h @@ -881,6 +881,7 @@ extern ssize_t open_read_close(const char *filename, void *buf, size_t maxsz) FA extern char *xmalloc_reads(int fd, size_t *maxsz_p) FAST_FUNC; /* Reads block up to *maxsz_p (default: INT_MAX - 4095) */ extern void *xmalloc_read(int fd, size_t *maxsz_p) FAST_FUNC RETURNS_MALLOC; +extern void *xmalloc_read_with_initial_buf(int fd, size_t *maxsz_p, char *buf, size_t total) FAST_FUNC; /* Returns NULL if file can't be opened (default max size: INT_MAX - 4095) */ extern void *xmalloc_open_read_close(const char *filename, size_t *maxsz_p) FAST_FUNC RETURNS_MALLOC; /* Never returns NULL */ -- cgit v1.2.3