4 #define _POSIX_C_SOURCE 200809L
23 static char** alloc(size_t const size
) {
24 return try_malloc(size
* sizeof(char*));
27 static bool adjust(size_t const len
, size_t* const size
) {
29 out_of_memory_if(*size
== SIZE_MAX
);
30 if (*size
> SIZE_MAX
/ 2u) {
42 .size
= 2u * sizeof(*words
.words
),
49 static void push(Words words
[static const 1], char* const s
) {
50 if (adjust(words
->len
* sizeof(*words
->words
), &words
->size
)) {
51 words
->words
= try_realloc(words
->words
, words
->size
);
53 words
->words
[words
->len
++] = s
;
56 static bool read_char(int const fd
, char* const c
) {
57 ssize_t
const len
= read(fd
, c
, 1u);
64 static ReadWord
read_word(int const fd
) {
68 w
.eof
= !read_char(fd
, &c
);
73 w
.word
= try_malloc(size
);
76 if (!read_char(fd
, &c
)) {
80 if (adjust(w
.len
, &size
)) {
81 w
.word
= try_realloc(w
.word
, size
);