diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2023-04-13 19:24:50 +0200 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2023-04-13 19:24:50 +0200 |
commit | 6d4d2f4ebfc4e4dfa29e9ef0e1703fb1a7a358c3 (patch) | |
tree | a2406e226e69ec57a1bc9f0d2d8895b2d96b61dc /tunnel | |
parent | e55358f685005d90bc745060bb43791f18f50d54 (diff) |
tools: ndk-compat: NDK now is minimum API 19
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'tunnel')
-rw-r--r-- | tunnel/tools/ndk-compat/compat.c | 52 | ||||
-rw-r--r-- | tunnel/tools/ndk-compat/compat.h | 6 |
2 files changed, 0 insertions, 58 deletions
diff --git a/tunnel/tools/ndk-compat/compat.c b/tunnel/tools/ndk-compat/compat.c index 2c54c086..c5ce85ec 100644 --- a/tunnel/tools/ndk-compat/compat.c +++ b/tunnel/tools/ndk-compat/compat.c @@ -6,58 +6,6 @@ #define FILE_IS_EMPTY -#if defined(__ANDROID_MIN_SDK_VERSION__) && __ANDROID_MIN_SDK_VERSION__ < 18 -#undef FILE_IS_EMPTY -#include <stdio.h> -#include <stdlib.h> - -ssize_t getdelim(char **buf, size_t *bufsiz, int delimiter, FILE *fp) -{ - char *ptr, *eptr; - - if (*buf == NULL || *bufsiz == 0) { - *bufsiz = BUFSIZ; - if ((*buf = malloc(*bufsiz)) == NULL) - return -1; - } - - for (ptr = *buf, eptr = *buf + *bufsiz;;) { - int c = fgetc(fp); - if (c == -1) { - if (feof(fp)) { - ssize_t diff = (ssize_t)(ptr - *buf); - if (diff != 0) { - *ptr = '\0'; - return diff; - } - } - return -1; - } - *ptr++ = c; - if (c == delimiter) { - *ptr = '\0'; - return ptr - *buf; - } - if (ptr + 2 >= eptr) { - char *nbuf; - size_t nbufsiz = *bufsiz * 2; - ssize_t d = ptr - *buf; - if ((nbuf = realloc(*buf, nbufsiz)) == NULL) - return -1; - *buf = nbuf; - *bufsiz = nbufsiz; - eptr = nbuf + nbufsiz; - ptr = nbuf + d; - } - } -} - -ssize_t getline(char **buf, size_t *bufsiz, FILE *fp) -{ - return getdelim(buf, bufsiz, '\n', fp); -} -#endif - #if defined(__ANDROID_MIN_SDK_VERSION__) && __ANDROID_MIN_SDK_VERSION__ < 24 #undef FILE_IS_EMPTY #include <string.h> diff --git a/tunnel/tools/ndk-compat/compat.h b/tunnel/tools/ndk-compat/compat.h index 32f6d799..7dfd8e14 100644 --- a/tunnel/tools/ndk-compat/compat.h +++ b/tunnel/tools/ndk-compat/compat.h @@ -4,12 +4,6 @@ * */ -#if defined(__ANDROID_MIN_SDK_VERSION__) && __ANDROID_MIN_SDK_VERSION__ < 18 -#include <stdio.h> -ssize_t getdelim(char **buf, size_t *bufsiz, int delimiter, FILE *fp); -ssize_t getline(char **buf, size_t *bufsiz, FILE *fp); -#endif - #if defined(__ANDROID_MIN_SDK_VERSION__) && __ANDROID_MIN_SDK_VERSION__ < 24 char *strchrnul(const char *s, int c); #endif |