Add an array.copy_from method.

This commit is contained in:
Nigel Tao committed 2017-09-22 16:32:11 +10:00
1 parent 569e800bac
commit ed8a91ef51
10 files changed
+116 -43

No files matched your search

+15
View File
@@ -165,6 +165,8 @@ typedef struct {
uint32_t f_n_bits;
uint32_t f_huffs[2][1234];
uint32_t f_n_huffs_bits[2];
uint8_t f_history[32768];
uint32_t f_history_index;
uint8_t f_code_lengths[320];
struct {
@@ -374,6 +376,13 @@ static inline puffs_base_slice_u8 puffs_base_slice_u8_suffix(
return s;
}
// puffs_base_slice_u8_copy_from calls memmove(dst.ptr, src.ptr, n) where n is
// the minimum of dst.len and src.len.
static inline void puffs_base_slice_u8_copy_from(puffs_base_slice_u8 dst,
puffs_base_slice_u8 src) {
memmove(dst.ptr, src.ptr, dst.len < src.len ? dst.len : src.len);
}
#endif // PUFFS_BASE_IMPL_H
// ---------------- Status Codes Implementations
@@ -640,6 +649,12 @@ puffs_flate_status puffs_flate_decoder_decode(puffs_flate_decoder* self,
.len = b_wptr_dst - a_dst.buf->ptr});
if (((uint64_t)(v_written.len)) >= 32768) {
v_written = puffs_base_slice_u8_suffix(v_written, 32768);
puffs_base_slice_u8_copy_from(
((puffs_base_slice_u8){
.ptr = self->private_impl.f_history,
.len = sizeof(self->private_impl.f_history)}),
v_written);
self->private_impl.f_history_index = 32768;
}
}
status = v_z;
+7
View File
@@ -347,6 +347,13 @@ static inline puffs_base_slice_u8 puffs_base_slice_u8_suffix(
return s;
}
// puffs_base_slice_u8_copy_from calls memmove(dst.ptr, src.ptr, n) where n is
// the minimum of dst.len and src.len.
static inline void puffs_base_slice_u8_copy_from(puffs_base_slice_u8 dst,
puffs_base_slice_u8 src) {
memmove(dst.ptr, src.ptr, dst.len < src.len ? dst.len : src.len);
}
#endif // PUFFS_BASE_IMPL_H
// ---------------- Status Codes Implementations
+2
View File
@@ -165,6 +165,8 @@ typedef struct {
uint32_t f_n_bits;
uint32_t f_huffs[2][1234];
uint32_t f_n_huffs_bits[2];
uint8_t f_history[32768];
uint32_t f_history_index;
uint8_t f_code_lengths[320];
struct {