mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-19 08:38:14 +01:00
Rename some I/O private methods
This commit is contained in:
1 parent
eb0cbd802a
commit
baf1b9f9e6
3 files changed
+135
-135
No files matched your search
@@ -3684,20 +3684,20 @@ wuffs_base__io_writer__is_valid(wuffs_base__io_writer o) {
|
||||
}
|
||||
|
||||
static inline uint32_t //
|
||||
wuffs_base__io_writer__copy_n_from_history(uint8_t** ptr_ptr,
|
||||
wuffs_base__io_writer__copy_n_from_history(uint8_t** ptr_iop_w,
|
||||
uint8_t* start,
|
||||
uint8_t* end,
|
||||
uint8_t* io1_w,
|
||||
uint32_t length,
|
||||
uint32_t distance) {
|
||||
if (!distance) {
|
||||
return 0;
|
||||
}
|
||||
uint8_t* ptr = *ptr_ptr;
|
||||
if ((size_t)(ptr - start) < (size_t)(distance)) {
|
||||
uint8_t* iop_w = *ptr_iop_w;
|
||||
if ((size_t)(iop_w - start) < (size_t)(distance)) {
|
||||
return 0;
|
||||
}
|
||||
start = ptr - distance;
|
||||
size_t n = end - ptr;
|
||||
start = iop_w - distance;
|
||||
size_t n = io1_w - iop_w;
|
||||
if ((size_t)(length) > n) {
|
||||
length = n;
|
||||
} else {
|
||||
@@ -3714,14 +3714,14 @@ wuffs_base__io_writer__copy_n_from_history(uint8_t** ptr_ptr,
|
||||
// Alternatively, or additionally, have a sloppy_copy_n_from_history method
|
||||
// that copies 8 bytes at a time, possibly writing more than length bytes?
|
||||
for (; n >= 3; n -= 3) {
|
||||
*ptr++ = *start++;
|
||||
*ptr++ = *start++;
|
||||
*ptr++ = *start++;
|
||||
*iop_w++ = *start++;
|
||||
*iop_w++ = *start++;
|
||||
*iop_w++ = *start++;
|
||||
}
|
||||
for (; n; n--) {
|
||||
*ptr++ = *start++;
|
||||
*iop_w++ = *start++;
|
||||
}
|
||||
*ptr_ptr = ptr;
|
||||
*ptr_iop_w = iop_w;
|
||||
return length;
|
||||
}
|
||||
|
||||
@@ -3729,84 +3729,84 @@ wuffs_base__io_writer__copy_n_from_history(uint8_t** ptr_ptr,
|
||||
// wuffs_base__io_writer__copy_n_from_history function above, but has stronger
|
||||
// pre-conditions. The caller needs to prove that:
|
||||
// - distance > 0
|
||||
// - distance <= (*ptr_ptr - start)
|
||||
// - length <= (end - *ptr_ptr)
|
||||
// - distance <= (*ptr_iop_w - start)
|
||||
// - length <= (io1_w - *ptr_iop_w)
|
||||
static inline uint32_t //
|
||||
wuffs_base__io_writer__copy_n_from_history_fast(uint8_t** ptr_ptr,
|
||||
wuffs_base__io_writer__copy_n_from_history_fast(uint8_t** ptr_iop_w,
|
||||
uint8_t* start,
|
||||
uint8_t* end,
|
||||
uint8_t* io1_w,
|
||||
uint32_t length,
|
||||
uint32_t distance) {
|
||||
uint8_t* ptr = *ptr_ptr;
|
||||
start = ptr - distance;
|
||||
uint8_t* iop_w = *ptr_iop_w;
|
||||
start = iop_w - distance;
|
||||
uint32_t n = length;
|
||||
for (; n >= 3; n -= 3) {
|
||||
*ptr++ = *start++;
|
||||
*ptr++ = *start++;
|
||||
*ptr++ = *start++;
|
||||
*iop_w++ = *start++;
|
||||
*iop_w++ = *start++;
|
||||
*iop_w++ = *start++;
|
||||
}
|
||||
for (; n; n--) {
|
||||
*ptr++ = *start++;
|
||||
*iop_w++ = *start++;
|
||||
}
|
||||
*ptr_ptr = ptr;
|
||||
*ptr_iop_w = iop_w;
|
||||
return length;
|
||||
}
|
||||
|
||||
static inline uint32_t //
|
||||
wuffs_base__io_writer__copy_n_from_reader(uint8_t** ptr_ioptr_w,
|
||||
uint8_t* iobounds1_w,
|
||||
wuffs_base__io_writer__copy_n_from_reader(uint8_t** ptr_iop_w,
|
||||
uint8_t* io1_w,
|
||||
uint32_t length,
|
||||
uint8_t** ptr_ioptr_r,
|
||||
uint8_t* iobounds1_r) {
|
||||
uint8_t* ioptr_w = *ptr_ioptr_w;
|
||||
uint8_t** ptr_iop_r,
|
||||
uint8_t* io1_r) {
|
||||
uint8_t* iop_w = *ptr_iop_w;
|
||||
size_t n = length;
|
||||
if (n > ((size_t)(iobounds1_w - ioptr_w))) {
|
||||
n = iobounds1_w - ioptr_w;
|
||||
if (n > ((size_t)(io1_w - iop_w))) {
|
||||
n = io1_w - iop_w;
|
||||
}
|
||||
uint8_t* ioptr_r = *ptr_ioptr_r;
|
||||
if (n > ((size_t)(iobounds1_r - ioptr_r))) {
|
||||
n = iobounds1_r - ioptr_r;
|
||||
uint8_t* iop_r = *ptr_iop_r;
|
||||
if (n > ((size_t)(io1_r - iop_r))) {
|
||||
n = io1_r - iop_r;
|
||||
}
|
||||
if (n > 0) {
|
||||
memmove(ioptr_w, ioptr_r, n);
|
||||
*ptr_ioptr_w += n;
|
||||
*ptr_ioptr_r += n;
|
||||
memmove(iop_w, iop_r, n);
|
||||
*ptr_iop_w += n;
|
||||
*ptr_iop_r += n;
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
static inline uint64_t //
|
||||
wuffs_base__io_writer__copy_from_slice(uint8_t** ptr_ioptr_w,
|
||||
uint8_t* iobounds1_w,
|
||||
wuffs_base__io_writer__copy_from_slice(uint8_t** ptr_iop_w,
|
||||
uint8_t* io1_w,
|
||||
wuffs_base__slice_u8 src) {
|
||||
uint8_t* ioptr_w = *ptr_ioptr_w;
|
||||
uint8_t* iop_w = *ptr_iop_w;
|
||||
size_t n = src.len;
|
||||
if (n > ((size_t)(iobounds1_w - ioptr_w))) {
|
||||
n = iobounds1_w - ioptr_w;
|
||||
if (n > ((size_t)(io1_w - iop_w))) {
|
||||
n = io1_w - iop_w;
|
||||
}
|
||||
if (n > 0) {
|
||||
memmove(ioptr_w, src.ptr, n);
|
||||
*ptr_ioptr_w += n;
|
||||
memmove(iop_w, src.ptr, n);
|
||||
*ptr_iop_w += n;
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
static inline uint32_t //
|
||||
wuffs_base__io_writer__copy_n_from_slice(uint8_t** ptr_ioptr_w,
|
||||
uint8_t* iobounds1_w,
|
||||
wuffs_base__io_writer__copy_n_from_slice(uint8_t** ptr_iop_w,
|
||||
uint8_t* io1_w,
|
||||
uint32_t length,
|
||||
wuffs_base__slice_u8 src) {
|
||||
uint8_t* ioptr_w = *ptr_ioptr_w;
|
||||
uint8_t* iop_w = *ptr_iop_w;
|
||||
size_t n = src.len;
|
||||
if (n > length) {
|
||||
n = length;
|
||||
}
|
||||
if (n > ((size_t)(iobounds1_w - ioptr_w))) {
|
||||
n = iobounds1_w - ioptr_w;
|
||||
if (n > ((size_t)(io1_w - iop_w))) {
|
||||
n = io1_w - iop_w;
|
||||
}
|
||||
if (n > 0) {
|
||||
memmove(ioptr_w, src.ptr, n);
|
||||
*ptr_ioptr_w += n;
|
||||
memmove(iop_w, src.ptr, n);
|
||||
*ptr_iop_w += n;
|
||||
}
|
||||
return n;
|
||||
}
|
||||
@@ -3814,8 +3814,8 @@ wuffs_base__io_writer__copy_n_from_slice(uint8_t** ptr_ioptr_w,
|
||||
static inline wuffs_base__empty_struct //
|
||||
wuffs_base__io_reader__set(wuffs_base__io_reader* o,
|
||||
wuffs_base__io_buffer* b,
|
||||
uint8_t** ptr_iop,
|
||||
uint8_t** ptr_io1,
|
||||
uint8_t** ptr_iop_r,
|
||||
uint8_t** ptr_io1_r,
|
||||
wuffs_base__slice_u8 data) {
|
||||
b->data = data;
|
||||
b->meta.wi = data.len;
|
||||
@@ -3826,17 +3826,17 @@ wuffs_base__io_reader__set(wuffs_base__io_reader* o,
|
||||
o->private_impl.buf = b;
|
||||
o->private_impl.mark = data.ptr;
|
||||
o->private_impl.limit = data.ptr + data.len;
|
||||
*ptr_iop = data.ptr;
|
||||
*ptr_io1 = data.ptr + data.len;
|
||||
*ptr_iop_r = data.ptr;
|
||||
*ptr_io1_r = data.ptr + data.len;
|
||||
return ((wuffs_base__empty_struct){});
|
||||
}
|
||||
|
||||
static inline wuffs_base__empty_struct //
|
||||
wuffs_base__io_reader__set_limit(wuffs_base__io_reader* o,
|
||||
uint8_t* ioptr_r,
|
||||
uint8_t* iop_r,
|
||||
uint64_t limit) {
|
||||
if (o && (((size_t)(o->private_impl.limit - ioptr_r)) > limit)) {
|
||||
o->private_impl.limit = ioptr_r + limit;
|
||||
if (o && (((size_t)(o->private_impl.limit - iop_r)) > limit)) {
|
||||
o->private_impl.limit = iop_r + limit;
|
||||
}
|
||||
return ((wuffs_base__empty_struct){});
|
||||
}
|
||||
@@ -3848,10 +3848,10 @@ wuffs_base__io_reader__set_mark(wuffs_base__io_reader* o, uint8_t* mark) {
|
||||
}
|
||||
|
||||
static inline wuffs_base__slice_u8 //
|
||||
wuffs_base__io_reader__take(uint8_t** ptr_iop, uint8_t* io1, uint64_t n) {
|
||||
if (n <= ((size_t)(io1 - *ptr_iop))) {
|
||||
uint8_t* p = *ptr_iop;
|
||||
*ptr_iop += n;
|
||||
wuffs_base__io_reader__take(uint8_t** ptr_iop_r, uint8_t* io1_r, uint64_t n) {
|
||||
if (n <= ((size_t)(io1_r - *ptr_iop_r))) {
|
||||
uint8_t* p = *ptr_iop_r;
|
||||
*ptr_iop_r += n;
|
||||
return ((wuffs_base__slice_u8){
|
||||
.ptr = p,
|
||||
.len = n,
|
||||
@@ -3863,8 +3863,8 @@ wuffs_base__io_reader__take(uint8_t** ptr_iop, uint8_t* io1, uint64_t n) {
|
||||
static inline wuffs_base__empty_struct //
|
||||
wuffs_base__io_writer__set(wuffs_base__io_writer* o,
|
||||
wuffs_base__io_buffer* b,
|
||||
uint8_t** ioptr1_ptr,
|
||||
uint8_t** ioptr2_ptr,
|
||||
uint8_t** ptr_iop_w,
|
||||
uint8_t** ptr_io1_w,
|
||||
wuffs_base__slice_u8 data) {
|
||||
b->data = data;
|
||||
b->meta.wi = 0;
|
||||
@@ -3875,8 +3875,8 @@ wuffs_base__io_writer__set(wuffs_base__io_writer* o,
|
||||
o->private_impl.buf = b;
|
||||
o->private_impl.mark = data.ptr;
|
||||
o->private_impl.limit = data.ptr + data.len;
|
||||
*ioptr1_ptr = data.ptr;
|
||||
*ioptr2_ptr = data.ptr + data.len;
|
||||
*ptr_iop_w = data.ptr;
|
||||
*ptr_io1_w = data.ptr + data.len;
|
||||
return ((wuffs_base__empty_struct){});
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user