mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-20 08:47:28 +01:00
Relocate some for-test-only set_limit methods
This commit is contained in:
1 parent
81decad445
commit
bf4aa38a84
9 files changed
+36
-241
No files matched your search
@@ -290,6 +290,40 @@ int test_main(int argc, char** argv, proc* tests, proc* benches) {
|
||||
// WUFFS_BASE_HEADER_H is where wuffs_base__io_buffer is defined.
|
||||
#ifdef WUFFS_BASE_HEADER_H
|
||||
|
||||
static inline wuffs_base__empty_struct wuffs_base__io_reader__set_limit(
|
||||
wuffs_base__io_reader* o,
|
||||
uint64_t limit) {
|
||||
if (o && o->private_impl.buf) {
|
||||
uint8_t* p = o->private_impl.buf->ptr + o->private_impl.buf->ri;
|
||||
uint8_t* q = o->private_impl.buf->ptr + o->private_impl.buf->wi;
|
||||
if (!o->private_impl.bounds[0]) {
|
||||
o->private_impl.bounds[0] = p;
|
||||
o->private_impl.bounds[1] = q;
|
||||
}
|
||||
if ((o->private_impl.bounds[1] - p) > limit) {
|
||||
o->private_impl.bounds[1] = p + limit;
|
||||
}
|
||||
}
|
||||
return ((wuffs_base__empty_struct){});
|
||||
}
|
||||
|
||||
static inline wuffs_base__empty_struct wuffs_base__io_writer__set_limit(
|
||||
wuffs_base__io_writer* o,
|
||||
uint64_t limit) {
|
||||
if (o && o->private_impl.buf) {
|
||||
uint8_t* p = o->private_impl.buf->ptr + o->private_impl.buf->wi;
|
||||
uint8_t* q = o->private_impl.buf->ptr + o->private_impl.buf->len;
|
||||
if (!o->private_impl.bounds[0]) {
|
||||
o->private_impl.bounds[0] = p;
|
||||
o->private_impl.bounds[1] = q;
|
||||
}
|
||||
if ((o->private_impl.bounds[1] - p) > limit) {
|
||||
o->private_impl.bounds[1] = p + limit;
|
||||
}
|
||||
}
|
||||
return ((wuffs_base__empty_struct){});
|
||||
}
|
||||
|
||||
bool read_file(wuffs_base__io_buffer* dst, const char* path) {
|
||||
if (!dst || !path) {
|
||||
FAIL("read_file: NULL argument");
|
||||
|
||||
Reference in new issue
Block a user