-
- BIO_METHOD *methods_ustream;
-
- methods_ustream = BIO_meth_new(100 | BIO_TYPE_SOURCE_SINK, "ustream");
- BIO_meth_set_write(methods_ustream, s_ustream_write);
- BIO_meth_set_read(methods_ustream, s_ustream_read);
- BIO_meth_set_puts(methods_ustream, s_ustream_puts);
- BIO_meth_set_gets(methods_ustream, s_ustream_gets);
- BIO_meth_set_ctrl(methods_ustream, s_ustream_ctrl);
- BIO_meth_set_create(methods_ustream, s_ustream_new);
- BIO_meth_set_destroy(methods_ustream, s_ustream_free);
- bio = BIO_new(methods_ustream);
- BIO_set_data(bio, s);
+ struct bio_ctx *ctx = calloc(1, sizeof(struct bio_ctx));
+
+ ctx->stream = s;
+ ctx->meth = BIO_meth_new(100 | BIO_TYPE_SOURCE_SINK, "ustream");
+
+ BIO_meth_set_write(ctx->meth, s_ustream_write);
+ BIO_meth_set_read(ctx->meth, s_ustream_read);
+ BIO_meth_set_puts(ctx->meth, s_ustream_puts);
+ BIO_meth_set_gets(ctx->meth, s_ustream_gets);
+ BIO_meth_set_ctrl(ctx->meth, s_ustream_ctrl);
+ BIO_meth_set_create(ctx->meth, s_ustream_new);
+ BIO_meth_set_destroy(ctx->meth, s_ustream_free);
+ bio = BIO_new(ctx->meth);
+ BIO_set_data(bio, ctx);