#include "wimlib/lz_mf.h"
#include "wimlib/lz_repsearch.h"
#include "wimlib/lzms.h"
+#include "wimlib/unaligned.h"
#include "wimlib/util.h"
#include <string.h>
/* Write a coding unit, unless it would underflow the buffer. */
if (os->next != os->begin)
- *--os->next = cpu_to_le16(os->bitbuf >> os->bitcount);
+ put_unaligned_u16_le(os->bitbuf >> os->bitcount, --os->next);
/* Optimization for call sites that never write more than 16
* bits at once. */
return false;
if (os->bitcount != 0)
- *--os->next = cpu_to_le16(os->bitbuf << (16 - os->bitcount));
+ put_unaligned_u16_le(os->bitbuf << (16 - os->bitcount), --os->next);
return true;
}
* ((rc->low >> 32) != 0, a.k.a. the carry bit is 1). */
do {
if (likely(rc->next >= rc->begin)) {
- if (rc->next != rc->end)
- *rc->next++ = cpu_to_le16(rc->cache +
- (u16)(rc->low >> 32));
+ if (rc->next != rc->end) {
+ put_unaligned_u16_le(rc->cache +
+ (u16)(rc->low >> 32),
+ rc->next++);
+ }
} else {
rc->next++;
}