diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2019-05-24 17:03:28 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2019-05-24 17:03:28 +0200 |
commit | dff2bd733fc2dac08d34f2cfad0e68aeb8e7a7a2 (patch) | |
tree | 0085fabf15b8ca5034636f39e97e9ba306ca7671 /libbb/read_printf.c | |
parent | 309f5e3775ed9cc0837c6d93482735bc4f117d5b (diff) | |
download | busybox-w32-dff2bd733fc2dac08d34f2cfad0e68aeb8e7a7a2.tar.gz busybox-w32-dff2bd733fc2dac08d34f2cfad0e68aeb8e7a7a2.tar.bz2 busybox-w32-dff2bd733fc2dac08d34f2cfad0e68aeb8e7a7a2.zip |
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 <vda.linux@googlemail.com>
Diffstat (limited to '')
-rw-r--r-- | libbb/read_printf.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/libbb/read_printf.c b/libbb/read_printf.c index b6a17cc36..cb582c080 100644 --- a/libbb/read_printf.c +++ b/libbb/read_printf.c | |||
@@ -102,10 +102,9 @@ char* FAST_FUNC xmalloc_reads(int fd, size_t *maxsz_p) | |||
102 | 102 | ||
103 | // Read (potentially big) files in one go. File size is estimated | 103 | // Read (potentially big) files in one go. File size is estimated |
104 | // by stat. Extra '\0' byte is appended. | 104 | // by stat. Extra '\0' byte is appended. |
105 | void* FAST_FUNC xmalloc_read(int fd, size_t *maxsz_p) | 105 | void* FAST_FUNC xmalloc_read_with_initial_buf(int fd, size_t *maxsz_p, char *buf, size_t total) |
106 | { | 106 | { |
107 | char *buf; | 107 | size_t size, rd_size; |
108 | size_t size, rd_size, total; | ||
109 | size_t to_read; | 108 | size_t to_read; |
110 | struct stat st; | 109 | struct stat st; |
111 | 110 | ||
@@ -118,8 +117,6 @@ void* FAST_FUNC xmalloc_read(int fd, size_t *maxsz_p) | |||
118 | /* In order to make such files readable, we add small const */ | 117 | /* In order to make such files readable, we add small const */ |
119 | size = (st.st_size | 0x3ff) + 1; | 118 | size = (st.st_size | 0x3ff) + 1; |
120 | 119 | ||
121 | total = 0; | ||
122 | buf = NULL; | ||
123 | while (1) { | 120 | while (1) { |
124 | if (to_read < size) | 121 | if (to_read < size) |
125 | size = to_read; | 122 | size = to_read; |
@@ -148,6 +145,11 @@ void* FAST_FUNC xmalloc_read(int fd, size_t *maxsz_p) | |||
148 | return buf; | 145 | return buf; |
149 | } | 146 | } |
150 | 147 | ||
148 | void* FAST_FUNC xmalloc_read(int fd, size_t *maxsz_p) | ||
149 | { | ||
150 | return xmalloc_read_with_initial_buf(fd, maxsz_p, NULL, 0); | ||
151 | } | ||
152 | |||
151 | #ifdef USING_LSEEK_TO_GET_SIZE | 153 | #ifdef USING_LSEEK_TO_GET_SIZE |
152 | /* Alternatively, file size can be obtained by lseek to the end. | 154 | /* Alternatively, file size can be obtained by lseek to the end. |
153 | * The code is slightly bigger. Retained in case fstat approach | 155 | * The code is slightly bigger. Retained in case fstat approach |