diff options
author | Andy Green <andy@warmcat.com> | 2019-08-17 20:46:53 +0100 |
---|---|---|
committer | Andy Green <andy@warmcat.com> | 2019-08-19 10:12:20 +0100 |
commit | c099e7be924b6aecc1af42b982298c7f51f5e7e8 (patch) | |
tree | f4873fa1f355fbb83093b2df181192c3297b9e82 /lib/roles/h1 | |
parent | 72b482ee15db80e5b0301592e5bb6214173185ee (diff) | |
download | libwebsockets-c099e7be924b6aecc1af42b982298c7f51f5e7e8.tar.gz |
client: do client stash in a single alloc
Improve the code around stash, getting rid of the strdups for a net
code reduction. Remove the special destroy helper for stash since
it becomes a one-liner.
Trade several stack allocs in the client reset function for a single
sized brief heap alloc to reduce peak stack alloc by around 700 bytes.
Diffstat (limited to 'lib/roles/h1')
-rw-r--r-- | lib/roles/h1/ops-h1.c | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/lib/roles/h1/ops-h1.c b/lib/roles/h1/ops-h1.c index 1ba6a66a..19285476 100644 --- a/lib/roles/h1/ops-h1.c +++ b/lib/roles/h1/ops-h1.c @@ -937,7 +937,7 @@ rops_client_bind_h1(struct lws *wsi, const struct lws_client_connect_info *i) * we can assign the user space now, otherwise do it after the * ws subprotocol negotiated */ - if (!wsi->user_space && wsi->stash->method) + if (!wsi->user_space && wsi->stash->cis[CIS_METHOD]) if (lws_ensure_user_space(wsi)) return 1; @@ -951,11 +951,8 @@ rops_client_bind_h1(struct lws *wsi, const struct lws_client_connect_info *i) * only try h2 if he assertively said to use h2 alpn, otherwise * ws implies alpn restriction to h1. */ - if (!wsi->stash->method && !wsi->stash->alpn) { - wsi->stash->alpn = lws_strdup("http/1.1"); - if (!wsi->stash->alpn) - return 1; - } + if (!wsi->stash->cis[CIS_METHOD] && !wsi->stash->cis[CIS_ALPN]) + wsi->stash->cis[CIS_ALPN] = "http/1.1"; /* if we went on the ah waiting list, it's ok, we can wait. * |