+ /* Assert that there are no output bytes between the ostream.output
+ * pointer and the ostream.next_bit_output pointer. This can only
+ * happen if bytes had been written at the ostream.output pointer before
+ * the last bit word was written to the stream. But, this does not
+ * occur since xpress_write_match() always finishes by writing some bits
+ * (a Huffman symbol), and the bitstream was just flushed. */
+ wimlib_assert(ostream.output - ostream.next_bit_output == 2);
+
+ /*
+ * The length of the compressed data is supposed to be the value of the
+ * ostream.output pointer before flushing, which is now the
+ * output.next_bit_output pointer after flushing.
+ *
+ * There will be an extra 2 bytes at the ostream.bit_output pointer,
+ * which is zeroed out. (These 2 bytes may be either the last bytes in
+ * the compressed data, in which case they are actually unnecessary, or
+ * they may precede a number of bytes embedded into the bitstream.)
+ */
+ if (ostream.bit_output >
+ (const u8*)__compressed_data + uncompressed_len - 3)
+ return 1;
+ *(u16*)ostream.bit_output = cpu_to_le16(0);
+ compressed_len = ostream.next_bit_output - (const u8*)__compressed_data;