@@ -284,6 +284,7 @@ static void wtf_stream_cleanup_send_context(wtf_stream* stream, wtf_internal_sen
284284 .user_context = stream -> user_context ,
285285 .send_complete = {.buffers = send_ctx -> buffers ,
286286 .buffer_count = send_ctx -> count ,
287+ .user_context = send_ctx -> user_context ,
287288 .cancelled = cancelled }};
288289 stream -> callback (& event );
289290 } else {
@@ -565,7 +566,7 @@ static wtf_result_t wtf_stream_validate_send_params(wtf_stream* stream, const wt
565566}
566567
567568wtf_result_t wtf_stream_send (wtf_stream * stream , const wtf_buffer_t * buffers , uint32_t buffer_count ,
568- bool fin )
569+ bool fin , void * user_context )
569570{
570571 wtf_result_t validation_result = wtf_stream_validate_send_params (stream , buffers , buffer_count );
571572 if (validation_result != WTF_SUCCESS ) {
@@ -576,9 +577,16 @@ wtf_result_t wtf_stream_send(wtf_stream* stream, const wtf_buffer_t* buffers, ui
576577 if (!send_ctx ) {
577578 return WTF_ERROR_OUT_OF_MEMORY ;
578579 }
580+ wtf_buffer_t * internal_buffers = malloc (sizeof * buffers * buffer_count );
581+ if (!internal_buffers ) {
582+ free (send_ctx );
583+ return WTF_ERROR_OUT_OF_MEMORY ;
584+ }
585+ memcpy (internal_buffers , buffers , sizeof * buffers * buffer_count );
579586
580- send_ctx -> buffers = ( wtf_buffer_t * ) buffers ;
587+ send_ctx -> buffers = internal_buffers ;
581588 send_ctx -> count = buffer_count ;
589+ send_ctx -> user_context = user_context ;
582590 send_ctx -> internal_send = false;
583591
584592 QUIC_SEND_FLAGS flags = QUIC_SEND_FLAG_NONE ;
@@ -598,6 +606,7 @@ wtf_result_t wtf_stream_send(wtf_stream* stream, const wtf_buffer_t* buffers, ui
598606 return WTF_SUCCESS ;
599607 }
600608
609+ free (send_ctx -> buffers );
601610 free (send_ctx );
602611 return wtf_quic_status_to_result (status );
603612}
@@ -656,7 +665,7 @@ wtf_result_t wtf_stream_close(wtf_stream_t* stream)
656665 mtx_unlock (& strm -> mutex );
657666
658667 wtf_buffer_t empty_buffer = {0 , NULL };
659- return wtf_stream_send (strm , & empty_buffer , 1 , true);
668+ return wtf_stream_send (strm , & empty_buffer , 1 , true, NULL );
660669}
661670
662671wtf_result_t wtf_stream_get_id (wtf_stream_t * stream , uint64_t * stream_id )
0 commit comments