Mercurial > libbuf
annotate buf_shrink.3 @ 22:d87e84936795
misc: update copyright years
author | David Demelier <markand@malikania.fr> |
---|---|
date | Wed, 24 Feb 2021 11:43:50 +0100 |
parents | 939fe74cd80a |
children | dbdc17e11648 |
rev | line source |
---|---|
0 | 1 .\" |
2 .\" buf_shrink.3 -- simple string buffer for C | |
3 .\" | |
22
d87e84936795
misc: update copyright years
David Demelier <markand@malikania.fr>
parents:
21
diff
changeset
|
4 .\" Copyright (c) 2019-2021 David Demelier <markand@malikania.fr> |
0 | 5 .\" |
6 .\" Permission to use, copy, modify, and/or distribute this software for any | |
7 .\" purpose with or without fee is hereby granted, provided that the above | |
8 .\" copyright notice and this permission notice appear in all copies. | |
9 .\" | |
10 .\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | |
11 .\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | |
12 .\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | |
13 .\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | |
14 .\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | |
15 .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | |
16 .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | |
17 .\" | |
22
d87e84936795
misc: update copyright years
David Demelier <markand@malikania.fr>
parents:
21
diff
changeset
|
18 .Dd October 29, 2019-2021 |
0 | 19 .Dt BUF_SHRINK 3 |
20 .Os | |
21 .\" NAME | |
22 .Sh NAME | |
23 .Nm buf_shrink | |
24 .Nd reduce the buffer to its minimal requirement | |
25 .\" SYNOPSIS | |
26 .Sh SYNOPSIS | |
27 .In buf.h | |
21
939fe74cd80a
buf: switch to int from bool
David Demelier <markand@malikania.fr>
parents:
0
diff
changeset
|
28 .Ft int |
0 | 29 .Fn buf_shrink "struct buf *b" |
30 .\" DESCRIPTION | |
31 .Sh DESCRIPTION | |
32 Reduce the buffer capacity specified by | |
33 .Fa b | |
34 to reduce memory usage. | |
35 .Pp | |
36 The | |
37 .Fn buf_shrink | |
38 function will reduce the buffer capacity to the exact buffer length. | |
39 If reallocation of the new memory region failed, the current buffer is kept and | |
40 its capacity is unchanged. | |
41 As such, it is perfectly safe to ignore the return value unless you really want | |
42 to reduce memory consumption | |
43 .\" RETURN VALUE | |
44 .Sh RETURN VALUE | |
45 If the buffer's length is 0, the function simply frees the underlying data and | |
21
939fe74cd80a
buf: switch to int from bool
David Demelier <markand@malikania.fr>
parents:
0
diff
changeset
|
46 return 0. |
0 | 47 .Pp |
48 Otherwise the | |
49 .Fn buf_shrink | |
21
939fe74cd80a
buf: switch to int from bool
David Demelier <markand@malikania.fr>
parents:
0
diff
changeset
|
50 function returns -1 in case of error and |
0 | 51 .Va errno |
52 is set to indicate the error. | |
53 .\" ERRORS | |
54 .Sh ERRORS | |
55 .Bl -tag -width Er | |
56 .It Bq Er ENOMEM | |
57 Memory reallocation failed. | |
58 .El | |
59 .\" SEE ALSO | |
60 .Sh SEE ALSO | |
61 .Xr libbuf 3 | |
62 .\" AUTHORS | |
63 .Sh AUTHORS | |
64 The | |
65 .Nm libbuf | |
66 library was written by | |
67 .An David Demelier <markand@malikania.fr> |