1e71b7053SJung-uk Kim=pod 2e71b7053SJung-uk Kim 3e71b7053SJung-uk Kim=head1 NAME 4e71b7053SJung-uk Kim 5*b077aed3SPierre ProncheryBIO_new_ex, BIO_new, BIO_up_ref, BIO_free, BIO_vfree, BIO_free_all 6e71b7053SJung-uk Kim- BIO allocation and freeing functions 7e71b7053SJung-uk Kim 8e71b7053SJung-uk Kim=head1 SYNOPSIS 9e71b7053SJung-uk Kim 10e71b7053SJung-uk Kim #include <openssl/bio.h> 11e71b7053SJung-uk Kim 12*b077aed3SPierre Pronchery BIO *BIO_new_ex(OSSL_LIB_CTX *libctx, const BIO_METHOD *type); 13e71b7053SJung-uk Kim BIO *BIO_new(const BIO_METHOD *type); 14e71b7053SJung-uk Kim int BIO_up_ref(BIO *a); 15e71b7053SJung-uk Kim int BIO_free(BIO *a); 16e71b7053SJung-uk Kim void BIO_vfree(BIO *a); 17e71b7053SJung-uk Kim void BIO_free_all(BIO *a); 18e71b7053SJung-uk Kim 19e71b7053SJung-uk Kim=head1 DESCRIPTION 20e71b7053SJung-uk Kim 21*b077aed3SPierre ProncheryThe BIO_new_ex() function returns a new BIO using method B<type> associated with 22*b077aed3SPierre Proncherythe library context I<libctx> (see OSSL_LIB_CTX(3)). The library context may be 23*b077aed3SPierre ProncheryNULL to indicate the default library context. 24*b077aed3SPierre Pronchery 25*b077aed3SPierre ProncheryThe BIO_new() is the same as BIO_new_ex() except the default library context is 26*b077aed3SPierre Proncheryalways used. 27e71b7053SJung-uk Kim 28e71b7053SJung-uk KimBIO_up_ref() increments the reference count associated with the BIO object. 29e71b7053SJung-uk Kim 30e71b7053SJung-uk KimBIO_free() frees up a single BIO, BIO_vfree() also frees up a single BIO 31e71b7053SJung-uk Kimbut it does not return a value. 32e71b7053SJung-uk KimIf B<a> is NULL nothing is done. 33e71b7053SJung-uk KimCalling BIO_free() may also have some effect 34e71b7053SJung-uk Kimon the underlying I/O structure, for example it may close the file being 35e71b7053SJung-uk Kimreferred to under certain circumstances. For more details see the individual 36e71b7053SJung-uk KimBIO_METHOD descriptions. 37e71b7053SJung-uk Kim 38e71b7053SJung-uk KimBIO_free_all() frees up an entire BIO chain, it does not halt if an error 39e71b7053SJung-uk Kimoccurs freeing up an individual BIO in the chain. 40e71b7053SJung-uk KimIf B<a> is NULL nothing is done. 41e71b7053SJung-uk Kim 42e71b7053SJung-uk Kim=head1 RETURN VALUES 43e71b7053SJung-uk Kim 44*b077aed3SPierre ProncheryBIO_new_ex() and BIO_new() return a newly created BIO or NULL if the call fails. 45e71b7053SJung-uk Kim 46e71b7053SJung-uk KimBIO_up_ref() and BIO_free() return 1 for success and 0 for failure. 47e71b7053SJung-uk Kim 48e71b7053SJung-uk KimBIO_free_all() and BIO_vfree() do not return values. 49e71b7053SJung-uk Kim 50e71b7053SJung-uk Kim=head1 NOTES 51e71b7053SJung-uk Kim 52e71b7053SJung-uk KimIf BIO_free() is called on a BIO chain it will only free one BIO resulting 53e71b7053SJung-uk Kimin a memory leak. 54e71b7053SJung-uk Kim 55e71b7053SJung-uk KimCalling BIO_free_all() on a single BIO has the same effect as calling BIO_free() 56e71b7053SJung-uk Kimon it other than the discarded return value. 57e71b7053SJung-uk Kim 58e71b7053SJung-uk Kim=head1 HISTORY 59e71b7053SJung-uk Kim 60e71b7053SJung-uk KimBIO_set() was removed in OpenSSL 1.1.0 as BIO type is now opaque. 61e71b7053SJung-uk Kim 62*b077aed3SPierre ProncheryBIO_new_ex() was added in OpenSSL 3.0. 63*b077aed3SPierre Pronchery 64da327cd2SJung-uk Kim=head1 EXAMPLES 65e71b7053SJung-uk Kim 66e71b7053SJung-uk KimCreate a memory BIO: 67e71b7053SJung-uk Kim 68e71b7053SJung-uk Kim BIO *mem = BIO_new(BIO_s_mem()); 69e71b7053SJung-uk Kim 70e71b7053SJung-uk Kim=head1 COPYRIGHT 71e71b7053SJung-uk Kim 72*b077aed3SPierre ProncheryCopyright 2000-2021 The OpenSSL Project Authors. All Rights Reserved. 73e71b7053SJung-uk Kim 74*b077aed3SPierre ProncheryLicensed under the Apache License 2.0 (the "License"). You may not use 75e71b7053SJung-uk Kimthis file except in compliance with the License. You can obtain a copy 76e71b7053SJung-uk Kimin the file LICENSE in the source distribution or at 77e71b7053SJung-uk KimL<https://www.openssl.org/source/license.html>. 78e71b7053SJung-uk Kim 79e71b7053SJung-uk Kim=cut 80