From 87abaa2f7926a29f245fdb76c9a67f00d005a816 Mon Sep 17 00:00:00 2001 From: Dmitry Simonenko Date: Mon, 27 Aug 2018 14:57:13 +0300 Subject: [PATCH] kiwi: add kiwi_read_startup_size() --- third_party/kiwi/kiwi/io.h | 30 +++++++++++------------------- 1 file changed, 11 insertions(+), 19 deletions(-) diff --git a/third_party/kiwi/kiwi/io.h b/third_party/kiwi/kiwi/io.h index b09ffdfa..4c50adff 100644 --- a/third_party/kiwi/kiwi/io.h +++ b/third_party/kiwi/kiwi/io.h @@ -119,25 +119,6 @@ kiwi_write(char **pos, char *buf, int size) *pos = *pos + size; } -KIWI_API static inline int -kiwi_read_startup(uint32_t *len, char **data, uint32_t *size) -{ - if (*size < sizeof(uint32_t)) - return sizeof(uint32_t) - *size; - /* len */ - uint32_t pos_size = *size; - char *pos = *data; - kiwi_read32(len, &pos, &pos_size); - uint32_t len_to_read; - len_to_read = *len - *size; - if (len_to_read > 0) - return len_to_read; - *data += *len; - *size -= *len; - *len -= sizeof(uint32_t); - return 0; -} - KIWI_API static inline int kiwi_read(uint32_t *len, char **data, uint32_t *size) { @@ -173,4 +154,15 @@ kiwi_read_size(char *data, uint32_t data_size) return size; } +KIWI_API static inline uint32_t +kiwi_read_startup_size(char *data, uint32_t data_size) +{ + assert(data_size >= sizeof(uint32_t)); + /* size */ + uint32_t size; + kiwi_read32(&size, &data, &data_size); + size -= sizeof(uint32_t); + return size; +} + #endif /* KIWI_IO_H */