1
0
Fork 0
mirror of https://github.com/warmcat/libwebsockets.git synced 2025-03-16 00:00:07 +01:00

lws_set_wsi_user: allow setting to override existing internal allocation

This commit is contained in:
Andy Green 2020-03-19 17:03:11 +00:00
parent 8aef4cc330
commit 77a1b4e058

View file

@ -637,14 +637,11 @@ lws_wsi_user(struct lws *wsi)
void
lws_set_wsi_user(struct lws *wsi, void *data)
{
/* client and user owns it... */
if (wsi->user_space_externally_allocated ||
/* server, and protocol can never own it, user can control it... */
(wsi->protocol && !wsi->protocol->per_session_data_size))
wsi->user_space = data;
else
lwsl_err("%s: Cannot set internally-allocated user_space\n",
__func__);
if (!wsi->user_space_externally_allocated && wsi->user_space)
lws_free(wsi->user_space);
wsi->user_space_externally_allocated = 1;
wsi->user_space = data;
}
struct lws *