Mercurial > libbuf
annotate buf-putc.c @ 22:d87e84936795
misc: update copyright years
author | David Demelier <markand@malikania.fr> |
---|---|
date | Wed, 24 Feb 2021 11:43:50 +0100 |
parents | 939fe74cd80a |
children |
rev | line source |
---|---|
0 | 1 /* |
2 * buf-putc.c -- 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 */ | |
18 | |
19 #include <assert.h> | |
20 | |
21 #include "buf.h" | |
22 #include "buf-int.h" | |
23 | |
21
939fe74cd80a
buf: switch to int from bool
David Demelier <markand@malikania.fr>
parents:
0
diff
changeset
|
24 int |
0 | 25 buf_putc(struct buf *b, char c) |
26 { | |
27 assert(b); | |
28 | |
21
939fe74cd80a
buf: switch to int from bool
David Demelier <markand@malikania.fr>
parents:
0
diff
changeset
|
29 if (_buf_grow(b, 1) < 0) |
939fe74cd80a
buf: switch to int from bool
David Demelier <markand@malikania.fr>
parents:
0
diff
changeset
|
30 return -1; |
0 | 31 |
32 b->data[b->length++] = c; | |
33 b->data[b->length] = 0; | |
34 | |
21
939fe74cd80a
buf: switch to int from bool
David Demelier <markand@malikania.fr>
parents:
0
diff
changeset
|
35 return 0; |
0 | 36 } |