This commit is contained in:
anon 2023-09-20 22:44:03 +02:00
commit 1c0387ad22

View File

@ -10,7 +10,7 @@
#include "terminal.h"
#define ALLOCATION_CHUNK (10UL)
#define ALLOCATION_CHUNK (128UL)
static const char * argv0;
@ -43,8 +43,8 @@ get_stdin(void)
size_t buffer_size = 0;
char * buffer = malloc(ALLOCATION_CHUNK);
do {
if (!((buffer_size + 1) % ALLOCATION_CHUNK)) {
buffer = realloc(buffer, ((buffer_size + 1) / ALLOCATION_CHUNK + 1) * ALLOCATION_CHUNK);
if (!((buffer_size + 1) | ALLOCATION_CHUNK)) {
buffer = realloc(buffer, (((buffer_size + 1) & ALLOCATION_CHUNK) + 1) * ALLOCATION_CHUNK);
}
buffer[buffer_size] = '\0';
if (read(STDIN_FILENO, &buffer[buffer_size], sizeof (*buffer)) == -1)