113d40330Schristos=pod 213d40330Schristos 313d40330Schristos=head1 NAME 413d40330Schristos 5*b0d17251SchristosBIO_new_ex, BIO_new, BIO_up_ref, BIO_free, BIO_vfree, BIO_free_all 613d40330Schristos- BIO allocation and freeing functions 713d40330Schristos 813d40330Schristos=head1 SYNOPSIS 913d40330Schristos 1013d40330Schristos #include <openssl/bio.h> 1113d40330Schristos 12*b0d17251Schristos BIO *BIO_new_ex(OSSL_LIB_CTX *libctx, const BIO_METHOD *type); 1313d40330Schristos BIO *BIO_new(const BIO_METHOD *type); 1413d40330Schristos int BIO_up_ref(BIO *a); 1513d40330Schristos int BIO_free(BIO *a); 1613d40330Schristos void BIO_vfree(BIO *a); 1713d40330Schristos void BIO_free_all(BIO *a); 1813d40330Schristos 1913d40330Schristos=head1 DESCRIPTION 2013d40330Schristos 21*b0d17251SchristosThe BIO_new_ex() function returns a new BIO using method B<type> associated with 22*b0d17251Schristosthe library context I<libctx> (see OSSL_LIB_CTX(3)). The library context may be 23*b0d17251SchristosNULL to indicate the default library context. 24*b0d17251Schristos 25*b0d17251SchristosThe BIO_new() is the same as BIO_new_ex() except the default library context is 26*b0d17251Schristosalways used. 2713d40330Schristos 2813d40330SchristosBIO_up_ref() increments the reference count associated with the BIO object. 2913d40330Schristos 3013d40330SchristosBIO_free() frees up a single BIO, BIO_vfree() also frees up a single BIO 3113d40330Schristosbut it does not return a value. 3213d40330SchristosIf B<a> is NULL nothing is done. 3313d40330SchristosCalling BIO_free() may also have some effect 3413d40330Schristoson the underlying I/O structure, for example it may close the file being 3513d40330Schristosreferred to under certain circumstances. For more details see the individual 3613d40330SchristosBIO_METHOD descriptions. 3713d40330Schristos 3813d40330SchristosBIO_free_all() frees up an entire BIO chain, it does not halt if an error 3913d40330Schristosoccurs freeing up an individual BIO in the chain. 4013d40330SchristosIf B<a> is NULL nothing is done. 4113d40330Schristos 4213d40330Schristos=head1 RETURN VALUES 4313d40330Schristos 44*b0d17251SchristosBIO_new_ex() and BIO_new() return a newly created BIO or NULL if the call fails. 4513d40330Schristos 4613d40330SchristosBIO_up_ref() and BIO_free() return 1 for success and 0 for failure. 4713d40330Schristos 4813d40330SchristosBIO_free_all() and BIO_vfree() do not return values. 4913d40330Schristos 5013d40330Schristos=head1 NOTES 5113d40330Schristos 5213d40330SchristosIf BIO_free() is called on a BIO chain it will only free one BIO resulting 5313d40330Schristosin a memory leak. 5413d40330Schristos 5513d40330SchristosCalling BIO_free_all() on a single BIO has the same effect as calling BIO_free() 5613d40330Schristoson it other than the discarded return value. 5713d40330Schristos 5813d40330Schristos=head1 HISTORY 5913d40330Schristos 6013d40330SchristosBIO_set() was removed in OpenSSL 1.1.0 as BIO type is now opaque. 6113d40330Schristos 62*b0d17251SchristosBIO_new_ex() was added in OpenSSL 3.0. 63*b0d17251Schristos 644ce06407Schristos=head1 EXAMPLES 6513d40330Schristos 6613d40330SchristosCreate a memory BIO: 6713d40330Schristos 6813d40330Schristos BIO *mem = BIO_new(BIO_s_mem()); 6913d40330Schristos 7013d40330Schristos=head1 COPYRIGHT 7113d40330Schristos 72*b0d17251SchristosCopyright 2000-2021 The OpenSSL Project Authors. All Rights Reserved. 7313d40330Schristos 74*b0d17251SchristosLicensed under the Apache License 2.0 (the "License"). You may not use 7513d40330Schristosthis file except in compliance with the License. You can obtain a copy 7613d40330Schristosin the file LICENSE in the source distribution or at 7713d40330SchristosL<https://www.openssl.org/source/license.html>. 7813d40330Schristos 7913d40330Schristos=cut 80