From a407458a893fd0716cfee564ad98756364c25a7a Mon Sep 17 00:00:00 2001 From: "@syxhe" Date: Mon, 24 Mar 2025 18:10:58 -0500 Subject: Change the name of readwholebuffer and writewholebuffer so that they won't autocomplete when typing "return" --- src/shared.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'src/shared.c') diff --git a/src/shared.c b/src/shared.c index 72ede56..cc11fe1 100644 --- a/src/shared.c +++ b/src/shared.c @@ -22,12 +22,14 @@ void* xreallocarray(void *ptr, size_t nmemb, size_t size) { return mem; } -int readwholebuffer(char **str, unsigned long int initsize, int fd) { +int rwbuf(char **str, unsigned long int initsize, int fd) { // Try to read bytes from fd into str // Bytes read == 0, return 0 // Bytes read < 0, free string, return -1; // When string hits capacity, double the capacity, and reallocate the string + const int ECODE = -100; + char *lstr = NULL, *tmp = NULL; ssize_t bytesread = -1; int csize = initsize, ccap = initsize; @@ -46,13 +48,13 @@ int readwholebuffer(char **str, unsigned long int initsize, int fd) { free(lstr); lstr = NULL; // Need to set this because of the break - bytesread = -100; + bytesread = ECODE; break; } lstr = tmp; } } - if(bytesread < 0 && bytesread != -100) { + if(bytesread < 0 && bytesread != ECODE) { if(___VXGG___VERBOSE_ERRORS___) error(0, errno, "Ran into a read() error"); @@ -67,7 +69,7 @@ int readwholebuffer(char **str, unsigned long int initsize, int fd) { error(0, errno, "Could not shrink lstr after reading buffer"); free(lstr); - bytesread = -100; + bytesread = ECODE; } lstr = tmp; } @@ -81,7 +83,7 @@ int readwholebuffer(char **str, unsigned long int initsize, int fd) { } -int writewholebuffer(int fd, const unsigned char *buf, int len) { +int wwbuf(int fd, const unsigned char *buf, int len) { int total = 0; int left = len; int n; -- cgit v1.2.3