diff options
| author | Xavier Del Campo Romero <xavi.dcr@tutanota.com> | 2023-09-09 02:30:37 +0200 |
|---|---|---|
| committer | Xavier Del Campo Romero <xavi.dcr@tutanota.com> | 2023-09-09 02:34:26 +0200 |
| commit | e81d1f6312de85e5640277f5968263aa8cd393db (patch) | |
| tree | 0b2cf6db8a39ca789a78238268ef8de0838c4522 /main.c | |
| parent | fcef3b99b86312aaeb9e1cae88179abbfda90dff (diff) | |
| download | slcl-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.
Diffstat (limited to 'main.c')
| -rw-r--r-- | main.c | 13 |
1 files changed, 2 insertions, 11 deletions
@@ -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); |
