* the chunks (4 bytes per entry). */
} _packed_attribute;
+static inline unsigned int
+get_chunk_entry_size(u64 res_size, bool is_alt)
+{
+ if (res_size <= UINT32_MAX || is_alt)
+ return 4;
+ else
+ return 8;
+}
+
/* Functions to read streams */
extern int
const u64 num_chunk_entries = (alt_chunk_table ? num_chunks : num_chunks - 1);
/* Set the size of each chunk table entry based on the resource's
- * uncompressed size. XXX: Does the alternate chunk table really
- * always have 4-byte entries? */
- const u64 chunk_entry_size =
- (rspec->uncompressed_size > (1ULL << 32) && !alt_chunk_table)
- ? 8 : 4;
+ * uncompressed size. */
+ const u64 chunk_entry_size = get_chunk_entry_size(rspec->uncompressed_size,
+ alt_chunk_table);
/* Calculate the size of the chunk table in bytes. */
const u64 chunk_table_size = num_chunk_entries * chunk_entry_size;
u64 chunks_start_offset;
};
-static u64
-get_chunk_entry_size(u64 res_size, int write_resource_flags)
-{
- if (res_size <= UINT32_MAX ||
- (write_resource_flags & WIM_RESHDR_FLAG_PACKED_STREAMS))
- return 4;
- else
- return 8;
-}
-
/* Reserve space for the chunk table and prepare to accumulate the chunk table
* in memory. */
static int
* are unknown. */
reserve_size = expected_num_chunk_entries *
get_chunk_entry_size(res_expected_size,
- ctx->write_resource_flags);
+ 0 != (ctx->write_resource_flags &
+ WIM_RESHDR_FLAG_PACKED_STREAMS));
if (ctx->write_resource_flags & WRITE_RESOURCE_FLAG_PACK_STREAMS)
reserve_size += sizeof(struct alt_chunk_table_header_disk);
memset(ctx->chunk_csizes, 0, reserve_size);
actual_num_chunk_entries--;
chunk_entry_size = get_chunk_entry_size(res_actual_size,
- ctx->write_resource_flags);
+ 0 != (ctx->write_resource_flags &
+ WIM_RESHDR_FLAG_PACKED_STREAMS));
typedef le64 __attribute__((may_alias)) aliased_le64_t;
typedef le32 __attribute__((may_alias)) aliased_le32_t;