xref: /onnv-gate/usr/src/common/openssl/doc/crypto/BIO_new.pod (revision 2175:b0b2f052a486)
1*2175Sjp161948=pod
2*2175Sjp161948
3*2175Sjp161948=head1 NAME
4*2175Sjp161948
5*2175Sjp161948BIO_new, BIO_set, BIO_free, BIO_vfree, BIO_free_all - BIO allocation and freeing functions
6*2175Sjp161948
7*2175Sjp161948=head1 SYNOPSIS
8*2175Sjp161948
9*2175Sjp161948 #include <openssl/bio.h>
10*2175Sjp161948
11*2175Sjp161948 BIO *	BIO_new(BIO_METHOD *type);
12*2175Sjp161948 int	BIO_set(BIO *a,BIO_METHOD *type);
13*2175Sjp161948 int	BIO_free(BIO *a);
14*2175Sjp161948 void	BIO_vfree(BIO *a);
15*2175Sjp161948 void	BIO_free_all(BIO *a);
16*2175Sjp161948
17*2175Sjp161948=head1 DESCRIPTION
18*2175Sjp161948
19*2175Sjp161948The BIO_new() function returns a new BIO using method B<type>.
20*2175Sjp161948
21*2175Sjp161948BIO_set() sets the method of an already existing BIO.
22*2175Sjp161948
23*2175Sjp161948BIO_free() frees up a single BIO, BIO_vfree() also frees up a single BIO
24*2175Sjp161948but it does not return a value. Calling BIO_free() may also have some effect
25*2175Sjp161948on the underlying I/O structure, for example it may close the file being
26*2175Sjp161948referred to under certain circumstances. For more details see the individual
27*2175Sjp161948BIO_METHOD descriptions.
28*2175Sjp161948
29*2175Sjp161948BIO_free_all() frees up an entire BIO chain, it does not halt if an error
30*2175Sjp161948occurs freeing up an individual BIO in the chain.
31*2175Sjp161948
32*2175Sjp161948=head1 RETURN VALUES
33*2175Sjp161948
34*2175Sjp161948BIO_new() returns a newly created BIO or NULL if the call fails.
35*2175Sjp161948
36*2175Sjp161948BIO_set(), BIO_free() return 1 for success and 0 for failure.
37*2175Sjp161948
38*2175Sjp161948BIO_free_all() and BIO_vfree() do not return values.
39*2175Sjp161948
40*2175Sjp161948=head1 NOTES
41*2175Sjp161948
42*2175Sjp161948Some BIOs (such as memory BIOs) can be used immediately after calling
43*2175Sjp161948BIO_new(). Others (such as file BIOs) need some additional initialization,
44*2175Sjp161948and frequently a utility function exists to create and initialize such BIOs.
45*2175Sjp161948
46*2175Sjp161948If BIO_free() is called on a BIO chain it will only free one BIO resulting
47*2175Sjp161948in a memory leak.
48*2175Sjp161948
49*2175Sjp161948Calling BIO_free_all() a single BIO has the same effect as calling BIO_free()
50*2175Sjp161948on it other than the discarded return value.
51*2175Sjp161948
52*2175Sjp161948Normally the B<type> argument is supplied by a function which returns a
53*2175Sjp161948pointer to a BIO_METHOD. There is a naming convention for such functions:
54*2175Sjp161948a source/sink BIO is normally called BIO_s_*() and a filter BIO
55*2175Sjp161948BIO_f_*();
56*2175Sjp161948
57*2175Sjp161948=head1 EXAMPLE
58*2175Sjp161948
59*2175Sjp161948Create a memory BIO:
60*2175Sjp161948
61*2175Sjp161948 BIO *mem = BIO_new(BIO_s_mem());
62*2175Sjp161948
63*2175Sjp161948=head1 SEE ALSO
64*2175Sjp161948
65*2175Sjp161948TBA
66