summaryrefslogtreecommitdiff
path: root/src/ext
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2018-07-10 10:23:29 -0400
committerNick Mathewson <nickm@torproject.org>2018-07-10 10:36:49 -0400
commitb04d719c1067dd1cf9b48295f1d0e7ed5adb7255 (patch)
tree72a2e38a6f703aa7d85b6736d5be62afa59044f0 /src/ext
parent1604c0fe0e5ce74538555c19a307ad38d0fca358 (diff)
downloadtor-b04d719c1067dd1cf9b48295f1d0e7ed5adb7255.tar.gz
tor-b04d719c1067dd1cf9b48295f1d0e7ed5adb7255.zip
Integrate getdelim() and getline() support into Tor.
Diffstat (limited to 'src/ext')
-rw-r--r--src/ext/getdelim.c16
1 files changed, 6 insertions, 10 deletions
diff --git a/src/ext/getdelim.c b/src/ext/getdelim.c
index 60df7e1b64..8254103ff9 100644
--- a/src/ext/getdelim.c
+++ b/src/ext/getdelim.c
@@ -30,21 +30,19 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#include <nbcompat.h>
-#include <nbcompat/stdio.h>
-#include <nbcompat/stdlib.h>
-
-#if !HAVE_GETDELIM
+#ifndef BUFSIZ
+#define BUFSIZ 512
+#endif
ssize_t
-getdelim(char **buf, size_t *bufsiz, int delimiter, FILE *fp)
+compat_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)
+ if ((*buf = raw_malloc(*bufsiz)) == NULL)
return -1;
}
@@ -69,7 +67,7 @@ getdelim(char **buf, size_t *bufsiz, int delimiter, FILE *fp)
char *nbuf;
size_t nbufsiz = *bufsiz * 2;
ssize_t d = ptr - *buf;
- if ((nbuf = realloc(*buf, nbufsiz)) == NULL)
+ if ((nbuf = raw_realloc(*buf, nbufsiz)) == NULL)
return -1;
*buf = nbuf;
*bufsiz = nbufsiz;
@@ -78,5 +76,3 @@ getdelim(char **buf, size_t *bufsiz, int delimiter, FILE *fp)
}
}
}
-
-#endif