From 3971d119c129bf5685f9fd14d0f1f785581c3565 Mon Sep 17 00:00:00 2001 From: Garrett D'Amore Date: Tue, 7 Oct 2025 20:03:32 -0700 Subject: options: string options are passed by reference This avoids needless allocations, and we offer for pipes (which need this because they might be ephemeral) the get_strdup, get_strcpy, and get_strlen forms. (Those do the copying or allocations while holding the pipe reference.) --- src/supplemental/websocket/websocket_test.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'src/supplemental') diff --git a/src/supplemental/websocket/websocket_test.c b/src/supplemental/websocket/websocket_test.c index 98bcf658..cb502ef4 100644 --- a/src/supplemental/websocket/websocket_test.c +++ b/src/supplemental/websocket/websocket_test.c @@ -13,7 +13,7 @@ #include "sha1.h" -#include +#include "../../testing/nuts.h" void test_websocket_wildcard(void) @@ -138,7 +138,7 @@ test_websocket_conn_props(void) nng_stream *c2 = NULL; char uri[64]; bool on; - char *str; + const char *str; uint16_t port; int rv; @@ -208,18 +208,14 @@ test_websocket_conn_props(void) NUTS_PASS( nng_stream_get_string(c1, NNG_OPT_WS_HEADER "NNG-Req", &str)); NUTS_MATCH(str, "True"); - nng_strfree(str); NUTS_PASS( nng_stream_get_string(c2, NNG_OPT_WS_HEADER "NNG-Rep", &str)); NUTS_MATCH(str, "True"); - nng_strfree(str); NUTS_PASS(nng_stream_get_string( c1, NNG_OPT_WS_HEADER "Sec-WebSocket-Version", &str)); - NUTS_TRUE(str != NULL); - NUTS_TRUE(strcmp(str, "13") == 0); - nng_strfree(str); + NUTS_MATCH(str, "13"); nng_stream_close(c1); nng_stream_close(c2); -- cgit v1.2.3-70-g09d2