aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXavier Del Campo Romero <xavi.dcr@tutanota.com>2023-09-09 02:30:37 +0200
committerXavier Del Campo Romero <xavi.dcr@tutanota.com>2023-09-09 02:34:26 +0200
commite81d1f6312de85e5640277f5968263aa8cd393db (patch)
tree0b2cf6db8a39ca789a78238268ef8de0838c4522
parentfcef3b99b86312aaeb9e1cae88179abbfda90dff (diff)
downloadslcl-e81d1f6312de85e5640277f5968263aa8cd393db.tar.gz
main.c: Remove string duplication in get_forms
slweb now assumes application/x-www-form-urlencoded-data as text, so it now returns a null-terminated string on struct http_post member "data". This removes the need for slcl to call strdup(3) in order to obtain a null-terminated string.
-rw-r--r--main.c13
m---------slweb0
2 files changed, 2 insertions, 11 deletions
diff --git a/main.c b/main.c
index 48c6617..f05d589 100644
--- a/main.c
+++ b/main.c
@@ -208,23 +208,16 @@ static int get_forms(const struct http_payload *const pl,
{
int ret = -1;
const struct http_post *const p = &pl->u.post;
- const char *const ref = p->data;
- char *dup = NULL;
struct form *f = NULL;
- if (!ref)
+ if (!p->data)
{
fprintf(stderr, "%s: expected non-NULL buffer\n", __func__);
ret = 1;
goto end;
}
- else if (!(dup = strndup(ref, p->n)))
- {
- fprintf(stderr, "%s: strndup(3): %s\n", __func__, strerror(errno));
- goto end;
- }
- const char *s = dup;
+ const char *s = p->data;
*outn = 0;
@@ -241,8 +234,6 @@ static int get_forms(const struct http_payload *const pl,
ret = 0;
end:
- free(dup);
-
if (ret)
forms_free(f, *outn);
diff --git a/slweb b/slweb
-Subproject 34d716082a0136056373f3d0c6ed7abce45484b
+Subproject 5be3ffdd3bfd96b314509f6f03e211e309d0fef