mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-17 16:32:11 +01:00
Rename FOO_BUFFER_SIZE to FOO_BUFFER_ARRAY_SIZE
This commit is contained in:
1 parent
01abc84784
commit
fdac24a425
12 files changed
+136
-126
No files matched your search
@@ -50,11 +50,11 @@ for a C++ compiler $CXX, such as clang++ or g++.
|
||||
// program to generate a stand-alone C++ file.
|
||||
#include "../../release/c/wuffs-unsupported-snapshot.c"
|
||||
|
||||
#ifndef SRC_BUFFER_SIZE
|
||||
#define SRC_BUFFER_SIZE (32 * 1024)
|
||||
#ifndef SRC_BUFFER_ARRAY_SIZE
|
||||
#define SRC_BUFFER_ARRAY_SIZE (32 * 1024)
|
||||
#endif
|
||||
|
||||
uint8_t src_buffer[SRC_BUFFER_SIZE];
|
||||
uint8_t src_buffer_array[SRC_BUFFER_ARRAY_SIZE];
|
||||
|
||||
int //
|
||||
main(int argc, char** argv) {
|
||||
@@ -66,8 +66,10 @@ main(int argc, char** argv) {
|
||||
}
|
||||
|
||||
while (true) {
|
||||
size_t n = fread(src_buffer, sizeof(uint8_t), SRC_BUFFER_SIZE, stdin);
|
||||
uint32_t checksum = h.update_u32(wuffs_base__make_slice_u8(src_buffer, n));
|
||||
size_t n =
|
||||
fread(src_buffer_array, sizeof(uint8_t), SRC_BUFFER_ARRAY_SIZE, stdin);
|
||||
uint32_t checksum =
|
||||
h.update_u32(wuffs_base__make_slice_u8(src_buffer_array, n));
|
||||
if (feof(stdin)) {
|
||||
printf("%08" PRIx32 "\n", checksum);
|
||||
return 0;
|
||||
|
||||
@@ -102,14 +102,14 @@ micros_since_start(struct timespec* now) {
|
||||
//
|
||||
// We keep the whole input in memory, instead of one-pass stream processing,
|
||||
// because playing a looping animation requires re-winding the input.
|
||||
#ifndef SRC_BUFFER_SIZE
|
||||
#define SRC_BUFFER_SIZE (64 * 1024 * 1024)
|
||||
#ifndef SRC_BUFFER_ARRAY_SIZE
|
||||
#define SRC_BUFFER_ARRAY_SIZE (64 * 1024 * 1024)
|
||||
#endif
|
||||
#ifndef MAX_DIMENSION
|
||||
#define MAX_DIMENSION (4096)
|
||||
#endif
|
||||
|
||||
uint8_t src_buffer[SRC_BUFFER_SIZE] = {0};
|
||||
uint8_t src_buffer_array[SRC_BUFFER_ARRAY_SIZE] = {0};
|
||||
size_t src_len = 0;
|
||||
|
||||
uint8_t* curr_dst_buffer = NULL;
|
||||
@@ -128,9 +128,9 @@ wuffs_base__flicks cumulative_delay_micros = 0;
|
||||
|
||||
const char* //
|
||||
read_stdin() {
|
||||
while (src_len < SRC_BUFFER_SIZE) {
|
||||
size_t n = fread(src_buffer + src_len, sizeof(uint8_t),
|
||||
SRC_BUFFER_SIZE - src_len, stdin);
|
||||
while (src_len < SRC_BUFFER_ARRAY_SIZE) {
|
||||
size_t n = fread(src_buffer_array + src_len, sizeof(uint8_t),
|
||||
SRC_BUFFER_ARRAY_SIZE - src_len, stdin);
|
||||
src_len += n;
|
||||
if (feof(stdin)) {
|
||||
return NULL;
|
||||
@@ -352,7 +352,7 @@ play() {
|
||||
}
|
||||
|
||||
wuffs_base__io_buffer src;
|
||||
src.data.ptr = src_buffer;
|
||||
src.data.ptr = src_buffer_array;
|
||||
src.data.len = src_len;
|
||||
src.meta.wi = src_len;
|
||||
src.meta.ri = 0;
|
||||
|
||||
@@ -67,7 +67,7 @@ The Escape key quits.
|
||||
#define MAX_DIMENSION 65535
|
||||
|
||||
#define NUM_BACKGROUND_COLORS 3
|
||||
#define SRC_BUFFER_SIZE (64 * 1024)
|
||||
#define SRC_BUFFER_ARRAY_SIZE (64 * 1024)
|
||||
|
||||
// Global variable names start with a "g_" prefix.
|
||||
|
||||
@@ -84,7 +84,7 @@ uint32_t g_height = 0;
|
||||
wuffs_base__slice_u8 g_workbuf_slice = {0};
|
||||
wuffs_base__slice_u8 g_pixbuf_slice = {0};
|
||||
wuffs_base__pixel_buffer g_pixbuf = {0};
|
||||
uint8_t g_src_buffer[SRC_BUFFER_SIZE] = {0};
|
||||
uint8_t g_src_buffer_array[SRC_BUFFER_ARRAY_SIZE] = {0};
|
||||
wuffs_base__io_buffer g_src = {0};
|
||||
wuffs_base__image_config g_image_config = {0};
|
||||
wuffs_base__image_decoder* g_image_decoder = NULL;
|
||||
@@ -123,7 +123,7 @@ load_image_type() {
|
||||
}
|
||||
|
||||
wuffs_base__status status;
|
||||
switch (g_src_buffer[0]) {
|
||||
switch (g_src_buffer_array[0]) {
|
||||
case '\x00':
|
||||
status = wuffs_wbmp__decoder__initialize(
|
||||
&g_potential_decoders.wbmp, sizeof g_potential_decoders.wbmp,
|
||||
@@ -297,8 +297,8 @@ load_image(const char* filename) {
|
||||
}
|
||||
g_width = 0;
|
||||
g_height = 0;
|
||||
g_src.data.ptr = g_src_buffer;
|
||||
g_src.data.len = SRC_BUFFER_SIZE;
|
||||
g_src.data.ptr = g_src_buffer_array;
|
||||
g_src.data.len = SRC_BUFFER_ARRAY_SIZE;
|
||||
g_src.meta.wi = 0;
|
||||
g_src.meta.ri = 0;
|
||||
g_src.meta.pos = 0;
|
||||
|
||||
+12
-12
@@ -168,19 +168,19 @@ int input_file_descriptor = 0; // A 0 default means stdin.
|
||||
#define INDENT_SPACES_STRING " "
|
||||
#define INDENT_TAB_STRING "\t"
|
||||
|
||||
#ifndef DST_BUFFER_SIZE
|
||||
#define DST_BUFFER_SIZE (32 * 1024)
|
||||
#ifndef DST_BUFFER_ARRAY_SIZE
|
||||
#define DST_BUFFER_ARRAY_SIZE (32 * 1024)
|
||||
#endif
|
||||
#ifndef SRC_BUFFER_SIZE
|
||||
#define SRC_BUFFER_SIZE (32 * 1024)
|
||||
#ifndef SRC_BUFFER_ARRAY_SIZE
|
||||
#define SRC_BUFFER_ARRAY_SIZE (32 * 1024)
|
||||
#endif
|
||||
#ifndef TOKEN_BUFFER_SIZE
|
||||
#define TOKEN_BUFFER_SIZE (4 * 1024)
|
||||
#ifndef TOKEN_BUFFER_ARRAY_SIZE
|
||||
#define TOKEN_BUFFER_ARRAY_SIZE (4 * 1024)
|
||||
#endif
|
||||
|
||||
uint8_t dst_array[DST_BUFFER_SIZE];
|
||||
uint8_t src_array[SRC_BUFFER_SIZE];
|
||||
wuffs_base__token tok_array[TOKEN_BUFFER_SIZE];
|
||||
uint8_t dst_array[DST_BUFFER_ARRAY_SIZE];
|
||||
uint8_t src_array[SRC_BUFFER_ARRAY_SIZE];
|
||||
wuffs_base__token tok_array[TOKEN_BUFFER_ARRAY_SIZE];
|
||||
|
||||
wuffs_base__io_buffer dst;
|
||||
wuffs_base__io_buffer src;
|
||||
@@ -513,15 +513,15 @@ parse_flags(int argc, char** argv) {
|
||||
const char* //
|
||||
initialize_globals(int argc, char** argv) {
|
||||
dst = wuffs_base__make_io_buffer(
|
||||
wuffs_base__make_slice_u8(dst_array, DST_BUFFER_SIZE),
|
||||
wuffs_base__make_slice_u8(dst_array, DST_BUFFER_ARRAY_SIZE),
|
||||
wuffs_base__empty_io_buffer_meta());
|
||||
|
||||
src = wuffs_base__make_io_buffer(
|
||||
wuffs_base__make_slice_u8(src_array, SRC_BUFFER_SIZE),
|
||||
wuffs_base__make_slice_u8(src_array, SRC_BUFFER_ARRAY_SIZE),
|
||||
wuffs_base__empty_io_buffer_meta());
|
||||
|
||||
tok = wuffs_base__make_token_buffer(
|
||||
wuffs_base__make_slice_token(tok_array, TOKEN_BUFFER_SIZE),
|
||||
wuffs_base__make_slice_token(tok_array, TOKEN_BUFFER_ARRAY_SIZE),
|
||||
wuffs_base__empty_token_buffer_meta());
|
||||
|
||||
curr_token_end_src_index = 0;
|
||||
|
||||
+11
-10
@@ -45,10 +45,10 @@ for a C compiler $CC, such as clang or gcc.
|
||||
#endif
|
||||
#include "wuffs/release/c/wuffs-unsupported-snapshot.c"
|
||||
|
||||
#ifndef DST_BUFFER_SIZE
|
||||
#define DST_BUFFER_SIZE 1024
|
||||
#ifndef DST_BUFFER_ARRAY_SIZE
|
||||
#define DST_BUFFER_ARRAY_SIZE 1024
|
||||
#endif
|
||||
uint8_t dst_buffer[DST_BUFFER_SIZE];
|
||||
uint8_t dst_buffer_array[DST_BUFFER_ARRAY_SIZE];
|
||||
|
||||
// src_ptr and src_len hold a gzip-encoded "Hello Wuffs."
|
||||
//
|
||||
@@ -68,19 +68,20 @@ uint8_t src_ptr[] = {
|
||||
};
|
||||
size_t src_len = 0x21;
|
||||
|
||||
#define WORK_BUFFER_SIZE WUFFS_GZIP__DECODER_WORKBUF_LEN_MAX_INCL_WORST_CASE
|
||||
#if WORK_BUFFER_SIZE > 0
|
||||
uint8_t work_buffer[WORK_BUFFER_SIZE];
|
||||
#define WORK_BUFFER_ARRAY_SIZE \
|
||||
WUFFS_GZIP__DECODER_WORKBUF_LEN_MAX_INCL_WORST_CASE
|
||||
#if WORK_BUFFER_ARRAY_SIZE > 0
|
||||
uint8_t work_buffer_array[WORK_BUFFER_ARRAY_SIZE];
|
||||
#else
|
||||
// Not all C/C++ compilers support 0-length arrays.
|
||||
uint8_t work_buffer[1];
|
||||
uint8_t work_buffer_array[1];
|
||||
#endif
|
||||
|
||||
static const char* //
|
||||
decode() {
|
||||
wuffs_base__io_buffer dst;
|
||||
dst.data.ptr = dst_buffer;
|
||||
dst.data.len = DST_BUFFER_SIZE;
|
||||
dst.data.ptr = dst_buffer_array;
|
||||
dst.data.len = DST_BUFFER_ARRAY_SIZE;
|
||||
dst.meta.wi = 0;
|
||||
dst.meta.ri = 0;
|
||||
dst.meta.pos = 0;
|
||||
@@ -108,7 +109,7 @@ decode() {
|
||||
}
|
||||
status = wuffs_gzip__decoder__transform_io(
|
||||
dec, &dst, &src,
|
||||
wuffs_base__make_slice_u8(work_buffer, WORK_BUFFER_SIZE));
|
||||
wuffs_base__make_slice_u8(work_buffer_array, WORK_BUFFER_ARRAY_SIZE));
|
||||
if (!wuffs_base__status__is_ok(&status)) {
|
||||
free(dec);
|
||||
return wuffs_base__status__message(&status);
|
||||
|
||||
+17
-16
@@ -61,23 +61,24 @@ for a C compiler $CC, such as clang or gcc.
|
||||
#define WUFFS_EXAMPLE_USE_SECCOMP
|
||||
#endif
|
||||
|
||||
#ifndef DST_BUFFER_SIZE
|
||||
#define DST_BUFFER_SIZE (128 * 1024)
|
||||
#ifndef DST_BUFFER_ARRAY_SIZE
|
||||
#define DST_BUFFER_ARRAY_SIZE (128 * 1024)
|
||||
#endif
|
||||
|
||||
#ifndef SRC_BUFFER_SIZE
|
||||
#define SRC_BUFFER_SIZE (128 * 1024)
|
||||
#ifndef SRC_BUFFER_ARRAY_SIZE
|
||||
#define SRC_BUFFER_ARRAY_SIZE (128 * 1024)
|
||||
#endif
|
||||
|
||||
#define WORK_BUFFER_SIZE WUFFS_GZIP__DECODER_WORKBUF_LEN_MAX_INCL_WORST_CASE
|
||||
#define WORK_BUFFER_ARRAY_SIZE \
|
||||
WUFFS_GZIP__DECODER_WORKBUF_LEN_MAX_INCL_WORST_CASE
|
||||
|
||||
uint8_t dst_buffer[DST_BUFFER_SIZE];
|
||||
uint8_t src_buffer[SRC_BUFFER_SIZE];
|
||||
#if WORK_BUFFER_SIZE > 0
|
||||
uint8_t work_buffer[WORK_BUFFER_SIZE];
|
||||
uint8_t dst_buffer_array[DST_BUFFER_ARRAY_SIZE];
|
||||
uint8_t src_buffer_array[SRC_BUFFER_ARRAY_SIZE];
|
||||
#if WORK_BUFFER_ARRAY_SIZE > 0
|
||||
uint8_t work_buffer_array[WORK_BUFFER_ARRAY_SIZE];
|
||||
#else
|
||||
// Not all C/C++ compilers support 0-length arrays.
|
||||
uint8_t work_buffer[1];
|
||||
uint8_t work_buffer_array[1];
|
||||
#endif
|
||||
|
||||
// ----
|
||||
@@ -150,16 +151,16 @@ main1(int argc, char** argv) {
|
||||
}
|
||||
|
||||
wuffs_base__io_buffer dst;
|
||||
dst.data.ptr = dst_buffer;
|
||||
dst.data.len = DST_BUFFER_SIZE;
|
||||
dst.data.ptr = dst_buffer_array;
|
||||
dst.data.len = DST_BUFFER_ARRAY_SIZE;
|
||||
dst.meta.wi = 0;
|
||||
dst.meta.ri = 0;
|
||||
dst.meta.pos = 0;
|
||||
dst.meta.closed = false;
|
||||
|
||||
wuffs_base__io_buffer src;
|
||||
src.data.ptr = src_buffer;
|
||||
src.data.len = SRC_BUFFER_SIZE;
|
||||
src.data.ptr = src_buffer_array;
|
||||
src.data.len = SRC_BUFFER_ARRAY_SIZE;
|
||||
src.meta.wi = 0;
|
||||
src.meta.ri = 0;
|
||||
src.meta.pos = 0;
|
||||
@@ -183,12 +184,12 @@ main1(int argc, char** argv) {
|
||||
while (true) {
|
||||
status = wuffs_gzip__decoder__transform_io(
|
||||
&dec, &dst, &src,
|
||||
wuffs_base__make_slice_u8(work_buffer, WORK_BUFFER_SIZE));
|
||||
wuffs_base__make_slice_u8(work_buffer_array, WORK_BUFFER_ARRAY_SIZE));
|
||||
|
||||
if (dst.meta.wi) {
|
||||
// TODO: handle EINTR and other write errors; see "man 2 write".
|
||||
const int stdout_fd = 1;
|
||||
ignore_return_value(write(stdout_fd, dst_buffer, dst.meta.wi));
|
||||
ignore_return_value(write(stdout_fd, dst_buffer_array, dst.meta.wi));
|
||||
dst.meta.ri = dst.meta.wi;
|
||||
wuffs_base__io_buffer__compact(&dst);
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ It should print "PASS", amongst other information, and exit(0).
|
||||
#include "../../../release/c/wuffs-unsupported-snapshot.c"
|
||||
#include "../fuzzlib/fuzzlib.c"
|
||||
|
||||
#define TOK_BUFFER_SIZE 4096
|
||||
#define TOK_BUFFER_ARRAY_SIZE 4096
|
||||
#define STACK_SIZE (WUFFS_JSON__DECODER_DEPTH_MAX_INCL + 1)
|
||||
|
||||
// Each stack element is 1 byte. The low 7 bits denote the container:
|
||||
@@ -225,11 +225,12 @@ fuzz_complex(wuffs_base__io_buffer* full_src, uint32_t hash_24_bits) {
|
||||
return wuffs_base__status__message(&status);
|
||||
}
|
||||
|
||||
wuffs_base__token tok_array[TOK_BUFFER_SIZE];
|
||||
wuffs_base__token tok_array[TOK_BUFFER_ARRAY_SIZE];
|
||||
wuffs_base__token_buffer tok = ((wuffs_base__token_buffer){
|
||||
.data = ((wuffs_base__slice_token){
|
||||
.ptr = tok_array,
|
||||
.len = (tok_limit < TOK_BUFFER_SIZE) ? tok_limit : TOK_BUFFER_SIZE,
|
||||
.len = (tok_limit < TOK_BUFFER_ARRAY_SIZE) ? tok_limit
|
||||
: TOK_BUFFER_ARRAY_SIZE,
|
||||
}),
|
||||
});
|
||||
|
||||
@@ -331,11 +332,11 @@ fuzz_simple(wuffs_base__io_buffer* full_src) {
|
||||
return wuffs_base__status__message(&status);
|
||||
}
|
||||
|
||||
wuffs_base__token tok_array[TOK_BUFFER_SIZE];
|
||||
wuffs_base__token tok_array[TOK_BUFFER_ARRAY_SIZE];
|
||||
wuffs_base__token_buffer tok = ((wuffs_base__token_buffer){
|
||||
.data = ((wuffs_base__slice_token){
|
||||
.ptr = tok_array,
|
||||
.len = TOK_BUFFER_SIZE,
|
||||
.len = TOK_BUFFER_ARRAY_SIZE,
|
||||
}),
|
||||
});
|
||||
|
||||
|
||||
+14
-12
@@ -61,16 +61,17 @@ It should print "PASS", amongst other information, and exit(0).
|
||||
#include "../../../release/c/wuffs-unsupported-snapshot.c"
|
||||
#include "../fuzzlib/fuzzlib.c"
|
||||
|
||||
#define DST_BUFFER_SIZE 65536
|
||||
#define DST_BUFFER_ARRAY_SIZE 65536
|
||||
|
||||
// Wuffs allows either statically or dynamically allocated work buffers. This
|
||||
// program exercises static allocation.
|
||||
#define WORK_BUFFER_SIZE WUFFS_ZLIB__DECODER_WORKBUF_LEN_MAX_INCL_WORST_CASE
|
||||
#if WORK_BUFFER_SIZE > 0
|
||||
uint8_t work_buffer[WORK_BUFFER_SIZE];
|
||||
#define WORK_BUFFER_ARRAY_SIZE \
|
||||
WUFFS_ZLIB__DECODER_WORKBUF_LEN_MAX_INCL_WORST_CASE
|
||||
#if WORK_BUFFER_ARRAY_SIZE > 0
|
||||
uint8_t work_buffer_array[WORK_BUFFER_ARRAY_SIZE];
|
||||
#else
|
||||
// Not all C/C++ compilers support 0-length arrays.
|
||||
uint8_t work_buffer[1];
|
||||
uint8_t work_buffer_array[1];
|
||||
#endif
|
||||
|
||||
const char* //
|
||||
@@ -88,21 +89,22 @@ fuzz(wuffs_base__io_buffer* src, uint32_t hash) {
|
||||
// verify that checksumming does not lead to e.g. buffer overflows.
|
||||
wuffs_zlib__decoder__set_ignore_checksum(&dec, hash & 0xFFFE);
|
||||
|
||||
uint8_t dst_buffer[DST_BUFFER_SIZE];
|
||||
uint8_t dst_buffer[DST_BUFFER_ARRAY_SIZE];
|
||||
wuffs_base__io_buffer dst = ((wuffs_base__io_buffer){
|
||||
.data = ((wuffs_base__slice_u8){
|
||||
.ptr = dst_buffer,
|
||||
.len = DST_BUFFER_SIZE,
|
||||
.len = DST_BUFFER_ARRAY_SIZE,
|
||||
}),
|
||||
});
|
||||
|
||||
while (true) {
|
||||
dst.meta.wi = 0;
|
||||
status = wuffs_zlib__decoder__transform_io(&dec, &dst, src,
|
||||
((wuffs_base__slice_u8){
|
||||
.ptr = work_buffer,
|
||||
.len = WORK_BUFFER_SIZE,
|
||||
}));
|
||||
status =
|
||||
wuffs_zlib__decoder__transform_io(&dec, &dst, src,
|
||||
((wuffs_base__slice_u8){
|
||||
.ptr = work_buffer_array,
|
||||
.len = WORK_BUFFER_ARRAY_SIZE,
|
||||
}));
|
||||
if (status.repr != wuffs_base__suspension__short_write) {
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -98,27 +98,28 @@ load_u32be(uint8_t* p) {
|
||||
// compressed, in up to 1024 IDAT chunks, and 256 MiB and 16384 × 16384 pixels
|
||||
// uncompressed. This is a limitation of this program (which uses the Wuffs
|
||||
// standard library), not a limitation of Wuffs per se.
|
||||
#define DST_BUFFER_SIZE (256 * 1024 * 1024)
|
||||
#define SRC_BUFFER_SIZE (64 * 1024 * 1024)
|
||||
#define DST_BUFFER_ARRAY_SIZE (256 * 1024 * 1024)
|
||||
#define SRC_BUFFER_ARRAY_SIZE (64 * 1024 * 1024)
|
||||
#define MAX_DIMENSION (16384)
|
||||
#define MAX_IDAT_CHUNKS (1024)
|
||||
|
||||
uint8_t dst_buffer[DST_BUFFER_SIZE] = {0};
|
||||
uint8_t dst_buffer_array[DST_BUFFER_ARRAY_SIZE] = {0};
|
||||
size_t dst_len = 0;
|
||||
uint8_t src_buffer[SRC_BUFFER_SIZE] = {0};
|
||||
uint8_t src_buffer_array[SRC_BUFFER_ARRAY_SIZE] = {0};
|
||||
size_t src_len = 0;
|
||||
uint8_t idat_buffer[SRC_BUFFER_SIZE] = {0};
|
||||
uint8_t idat_buffer_array[SRC_BUFFER_ARRAY_SIZE] = {0};
|
||||
// The n'th IDAT chunk data (where n is a zero-based count) is in
|
||||
// idat_buffer[i:j], where i = idat_splits[n+0] and j = idat_splits[n+1].
|
||||
// idat_buffer_array[i:j], where i = idat_splits[n+0] and j = idat_splits[n+1].
|
||||
size_t idat_splits[MAX_IDAT_CHUNKS + 1] = {0};
|
||||
uint32_t num_idat_chunks = 0;
|
||||
|
||||
#define WORK_BUFFER_SIZE WUFFS_ZLIB__DECODER_WORKBUF_LEN_MAX_INCL_WORST_CASE
|
||||
#if WORK_BUFFER_SIZE > 0
|
||||
uint8_t work_buffer[WORK_BUFFER_SIZE];
|
||||
#define WORK_BUFFER_ARRAY_SIZE \
|
||||
WUFFS_ZLIB__DECODER_WORKBUF_LEN_MAX_INCL_WORST_CASE
|
||||
#if WORK_BUFFER_ARRAY_SIZE > 0
|
||||
uint8_t work_buffer_array[WORK_BUFFER_ARRAY_SIZE];
|
||||
#else
|
||||
// Not all C/C++ compilers support 0-length arrays.
|
||||
uint8_t work_buffer[1];
|
||||
uint8_t work_buffer_array[1];
|
||||
#endif
|
||||
|
||||
uint32_t width = 0;
|
||||
@@ -129,9 +130,10 @@ uint64_t bytes_per_frame = 0;
|
||||
|
||||
const char* //
|
||||
read_stdin() {
|
||||
while (src_len < SRC_BUFFER_SIZE) {
|
||||
while (src_len < SRC_BUFFER_ARRAY_SIZE) {
|
||||
const int stdin_fd = 0;
|
||||
ssize_t n = read(stdin_fd, src_buffer + src_len, SRC_BUFFER_SIZE - src_len);
|
||||
ssize_t n = read(stdin_fd, src_buffer_array + src_len,
|
||||
SRC_BUFFER_ARRAY_SIZE - src_len);
|
||||
if (n > 0) {
|
||||
src_len += n;
|
||||
} else if (n == 0) {
|
||||
@@ -209,7 +211,7 @@ process_png_chunks(uint8_t* p, size_t n) {
|
||||
if (num_idat_chunks == MAX_IDAT_CHUNKS - 1) {
|
||||
return "too many IDAT chunks";
|
||||
}
|
||||
memcpy(idat_buffer + idat_splits[num_idat_chunks], p, chunk_len);
|
||||
memcpy(idat_buffer_array + idat_splits[num_idat_chunks], p, chunk_len);
|
||||
idat_splits[num_idat_chunks + 1] =
|
||||
idat_splits[num_idat_chunks] + chunk_len;
|
||||
num_idat_chunks++;
|
||||
@@ -239,14 +241,14 @@ decode_once(bool frag_dst, bool frag_idat) {
|
||||
|
||||
wuffs_base__io_buffer dst = ((wuffs_base__io_buffer){
|
||||
.data = ((wuffs_base__slice_u8){
|
||||
.ptr = dst_buffer,
|
||||
.ptr = dst_buffer_array,
|
||||
.len = bytes_per_frame,
|
||||
}),
|
||||
});
|
||||
wuffs_base__io_buffer idat = ((wuffs_base__io_buffer){
|
||||
.data = ((wuffs_base__slice_u8){
|
||||
.ptr = idat_buffer,
|
||||
.len = SRC_BUFFER_SIZE,
|
||||
.ptr = idat_buffer_array,
|
||||
.len = SRC_BUFFER_ARRAY_SIZE,
|
||||
}),
|
||||
.meta = ((wuffs_base__io_buffer_meta){
|
||||
.wi = idat_splits[num_idat_chunks],
|
||||
@@ -268,11 +270,12 @@ decode_once(bool frag_dst, bool frag_idat) {
|
||||
}
|
||||
|
||||
while (true) {
|
||||
status = wuffs_zlib__decoder__transform_io(&dec, &dst, &idat,
|
||||
((wuffs_base__slice_u8){
|
||||
.ptr = work_buffer,
|
||||
.len = WORK_BUFFER_SIZE,
|
||||
}));
|
||||
status =
|
||||
wuffs_zlib__decoder__transform_io(&dec, &dst, &idat,
|
||||
((wuffs_base__slice_u8){
|
||||
.ptr = work_buffer_array,
|
||||
.len = WORK_BUFFER_ARRAY_SIZE,
|
||||
}));
|
||||
|
||||
if (wuffs_base__status__is_ok(&status)) {
|
||||
break;
|
||||
@@ -356,10 +359,10 @@ main(int argc, char** argv) {
|
||||
return fail(msg);
|
||||
}
|
||||
if ((src_len < 8) ||
|
||||
strncmp((const char*)(src_buffer), "\x89PNG\x0D\x0A\x1A\x0A", 8)) {
|
||||
strncmp((const char*)(src_buffer_array), "\x89PNG\x0D\x0A\x1A\x0A", 8)) {
|
||||
return fail("invalid PNG");
|
||||
}
|
||||
msg = process_png_chunks(src_buffer + 8, src_len - 8);
|
||||
msg = process_png_chunks(src_buffer_array + 8, src_len - 8);
|
||||
if (msg) {
|
||||
return fail(msg);
|
||||
}
|
||||
@@ -372,7 +375,7 @@ main(int argc, char** argv) {
|
||||
// The +1 here is for the per-row filter byte.
|
||||
bytes_per_row = (uint64_t)width * bytes_per_pixel + 1;
|
||||
bytes_per_frame = (uint64_t)height * bytes_per_row;
|
||||
if (bytes_per_frame > DST_BUFFER_SIZE) {
|
||||
if (bytes_per_frame > DST_BUFFER_ARRAY_SIZE) {
|
||||
return fail("decompressed data is too large");
|
||||
}
|
||||
|
||||
|
||||
@@ -84,15 +84,15 @@
|
||||
// program to generate a stand-alone C++ file.
|
||||
#include "../release/c/wuffs-unsupported-snapshot.c"
|
||||
|
||||
#ifndef SRC_BUFFER_SIZE
|
||||
#define SRC_BUFFER_SIZE (64 * 1024 * 1024)
|
||||
#ifndef SRC_BUFFER_ARRAY_SIZE
|
||||
#define SRC_BUFFER_ARRAY_SIZE (64 * 1024 * 1024)
|
||||
#endif
|
||||
#ifndef TOKEN_BUFFER_SIZE
|
||||
#define TOKEN_BUFFER_SIZE (128 * 1024)
|
||||
#ifndef TOKEN_BUFFER_ARRAY_SIZE
|
||||
#define TOKEN_BUFFER_ARRAY_SIZE (128 * 1024)
|
||||
#endif
|
||||
|
||||
uint8_t src_buffer[SRC_BUFFER_SIZE];
|
||||
wuffs_base__token tok_buffer[TOKEN_BUFFER_SIZE];
|
||||
uint8_t src_buffer_array[SRC_BUFFER_ARRAY_SIZE];
|
||||
wuffs_base__token tok_buffer_array[TOKEN_BUFFER_ARRAY_SIZE];
|
||||
|
||||
wuffs_base__io_buffer src;
|
||||
wuffs_base__token_buffer tok;
|
||||
@@ -205,11 +205,11 @@ main1(int argc, char** argv) {
|
||||
}
|
||||
|
||||
src = wuffs_base__make_io_buffer(
|
||||
wuffs_base__make_slice_u8(src_buffer, SRC_BUFFER_SIZE),
|
||||
wuffs_base__make_slice_u8(src_buffer_array, SRC_BUFFER_ARRAY_SIZE),
|
||||
wuffs_base__empty_io_buffer_meta());
|
||||
|
||||
tok = wuffs_base__make_token_buffer(
|
||||
wuffs_base__make_slice_token(tok_buffer, TOKEN_BUFFER_SIZE),
|
||||
wuffs_base__make_slice_token(tok_buffer_array, TOKEN_BUFFER_ARRAY_SIZE),
|
||||
wuffs_base__empty_token_buffer_meta());
|
||||
|
||||
wuffs_base__status init_status = wuffs_json__decoder__initialize(
|
||||
|
||||
+1
-1
@@ -626,7 +626,7 @@ test_wuffs_json_decode_prior_valid_utf_8() {
|
||||
.ptr = global_src_array,
|
||||
.len = 1 + prefix + n + suffix,
|
||||
});
|
||||
if (src_data.len > IO_BUFFER_SIZE) {
|
||||
if (src_data.len > IO_BUFFER_ARRAY_SIZE) {
|
||||
RETURN_FAIL("total src length is too long");
|
||||
}
|
||||
src_data.ptr[0] = '\"';
|
||||
|
||||
+21
-21
@@ -20,21 +20,21 @@
|
||||
#include <sys/time.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#define IO_BUFFER_SIZE (64 * 1024 * 1024)
|
||||
#define PIXEL_BUFFER_SIZE (64 * 1024 * 1024)
|
||||
#define TOKEN_BUFFER_SIZE (128 * 1024)
|
||||
#define IO_BUFFER_ARRAY_SIZE (64 * 1024 * 1024)
|
||||
#define PIXEL_BUFFER_ARRAY_SIZE (64 * 1024 * 1024)
|
||||
#define TOKEN_BUFFER_ARRAY_SIZE (128 * 1024)
|
||||
|
||||
#define WUFFS_TESTLIB_ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
|
||||
|
||||
uint8_t global_have_array[IO_BUFFER_SIZE];
|
||||
uint8_t global_want_array[IO_BUFFER_SIZE];
|
||||
uint8_t global_work_array[IO_BUFFER_SIZE];
|
||||
uint8_t global_src_array[IO_BUFFER_SIZE];
|
||||
uint8_t global_have_array[IO_BUFFER_ARRAY_SIZE];
|
||||
uint8_t global_want_array[IO_BUFFER_ARRAY_SIZE];
|
||||
uint8_t global_work_array[IO_BUFFER_ARRAY_SIZE];
|
||||
uint8_t global_src_array[IO_BUFFER_ARRAY_SIZE];
|
||||
|
||||
uint8_t global_pixel_array[PIXEL_BUFFER_SIZE];
|
||||
uint8_t global_pixel_array[PIXEL_BUFFER_ARRAY_SIZE];
|
||||
|
||||
wuffs_base__token global_have_token_array[TOKEN_BUFFER_SIZE];
|
||||
wuffs_base__token global_want_token_array[TOKEN_BUFFER_SIZE];
|
||||
wuffs_base__token global_have_token_array[TOKEN_BUFFER_ARRAY_SIZE];
|
||||
wuffs_base__token global_want_token_array[TOKEN_BUFFER_ARRAY_SIZE];
|
||||
|
||||
wuffs_base__slice_u8 global_have_slice;
|
||||
wuffs_base__slice_u8 global_want_slice;
|
||||
@@ -49,32 +49,32 @@ wuffs_base__slice_token global_want_token_slice;
|
||||
void wuffs_testlib__initialize_global_xxx_slices() {
|
||||
global_have_slice = ((wuffs_base__slice_u8){
|
||||
.ptr = global_have_array,
|
||||
.len = IO_BUFFER_SIZE,
|
||||
.len = IO_BUFFER_ARRAY_SIZE,
|
||||
});
|
||||
global_want_slice = ((wuffs_base__slice_u8){
|
||||
.ptr = global_want_array,
|
||||
.len = IO_BUFFER_SIZE,
|
||||
.len = IO_BUFFER_ARRAY_SIZE,
|
||||
});
|
||||
global_work_slice = ((wuffs_base__slice_u8){
|
||||
.ptr = global_work_array,
|
||||
.len = IO_BUFFER_SIZE,
|
||||
.len = IO_BUFFER_ARRAY_SIZE,
|
||||
});
|
||||
global_src_slice = ((wuffs_base__slice_u8){
|
||||
.ptr = global_src_array,
|
||||
.len = IO_BUFFER_SIZE,
|
||||
.len = IO_BUFFER_ARRAY_SIZE,
|
||||
});
|
||||
global_pixel_slice = ((wuffs_base__slice_u8){
|
||||
.ptr = global_pixel_array,
|
||||
.len = PIXEL_BUFFER_SIZE,
|
||||
.len = PIXEL_BUFFER_ARRAY_SIZE,
|
||||
});
|
||||
|
||||
global_have_token_slice = ((wuffs_base__slice_token){
|
||||
.ptr = global_have_token_array,
|
||||
.len = TOKEN_BUFFER_SIZE,
|
||||
.len = TOKEN_BUFFER_ARRAY_SIZE,
|
||||
});
|
||||
global_want_token_slice = ((wuffs_base__slice_token){
|
||||
.ptr = global_want_token_array,
|
||||
.len = TOKEN_BUFFER_SIZE,
|
||||
.len = TOKEN_BUFFER_ARRAY_SIZE,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1002,7 +1002,7 @@ do_test__wuffs_base__image_decoder(
|
||||
uint32_t want_height,
|
||||
wuffs_base__color_u32_argb_premul want_final_pixel) {
|
||||
if ((want_width > 16384) || (want_height > 16384) ||
|
||||
((want_width * want_height * 4) > PIXEL_BUFFER_SIZE)) {
|
||||
((want_width * want_height * 4) > PIXEL_BUFFER_ARRAY_SIZE)) {
|
||||
return "want dimensions are too large";
|
||||
}
|
||||
|
||||
@@ -1038,7 +1038,7 @@ do_test__wuffs_base__image_decoder(
|
||||
uint64_t n = wuffs_base__pixel_config__pixbuf_len(&ic.pixcfg);
|
||||
if (n < 4) {
|
||||
RETURN_FAIL("pixbuf_len too small");
|
||||
} else if (n > PIXEL_BUFFER_SIZE) {
|
||||
} else if (n > PIXEL_BUFFER_ARRAY_SIZE) {
|
||||
RETURN_FAIL("pixbuf_len too large");
|
||||
} else {
|
||||
wuffs_base__color_u32_argb_premul have_final_pixel =
|
||||
@@ -1068,7 +1068,7 @@ do_test__wuffs_base__io_transformer(wuffs_base__io_transformer* b,
|
||||
size_t src_wi,
|
||||
size_t want_wi,
|
||||
uint8_t want_final_byte) {
|
||||
if (want_wi > IO_BUFFER_SIZE) {
|
||||
if (want_wi > IO_BUFFER_ARRAY_SIZE) {
|
||||
return "want_wi is too large";
|
||||
}
|
||||
wuffs_base__range_ii_u64 workbuf_len =
|
||||
@@ -1076,7 +1076,7 @@ do_test__wuffs_base__io_transformer(wuffs_base__io_transformer* b,
|
||||
if (workbuf_len.min_incl > workbuf_len.max_incl) {
|
||||
return "inconsistent workbuf_len";
|
||||
}
|
||||
if (workbuf_len.max_incl > IO_BUFFER_SIZE) {
|
||||
if (workbuf_len.max_incl > IO_BUFFER_ARRAY_SIZE) {
|
||||
return "workbuf_len is too large";
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user