http-parser.c

Small C library to parse HTTP requests
Log | Files | Refs | README | LICENSE

commit 6201d0cf113c4af64c6ce99dde1861c511e350ca
parent 54e36aaa0c187e5d8a9513741733004af3f39d9f
Author: finwo <finwo@pm.me>
Date:   Tue, 24 Oct 2023 00:41:08 +0200

Using finwo/asprintf library instead of maintaining apsrintf polyfill here

Diffstat:
Mpackage.ini | 1+
Msrc/http-parser.c | 14+-------------
2 files changed, 2 insertions(+), 13 deletions(-)

diff --git a/package.ini b/package.ini @@ -1,4 +1,5 @@ [dependencies] +finwo/asprintf=https://github.com/finwo/c-asprintf/archive/refs/tags/edge.tar.gz finwo/str_extra=https://github.com/finwo/c-strextra/archive/refs/tags/edge.tar.gz tidwall/buf=https://raw.githubusercontent.com/finwo/dep-repository/main/tidwall/buf/package.ini [export] diff --git a/src/http-parser.c b/src/http-parser.c @@ -8,6 +8,7 @@ extern "C" { #include <string.h> #include <strings.h> +#include "finwo/asprintf.h" #include "finwo/strnstr.h" #include "tidwall/buf.h" @@ -49,19 +50,6 @@ int xtoi(char *str) { return sign * i; } -#ifndef _GNU_SOURCE -// Polyfill asprintf, comes from stdio when _GNU_SOURCE is defined -char * asprintf(char **restrict strp, const char *restrict fmt, ...) { - va_list argptr; - va_start(argptr, fmt); - int size = vsnprintf(NULL, 0, fmt, argptr); - char *output = calloc(1, size + 1); - vsnprintf(output, size + 1, fmt, argptr); - va_end(argptr); - return output; -} -#endif - /** * Frees everything in a header that was malloc'd by http-parser */