Mercurial > libbuf
comparison buf-dup.c @ 21:939fe74cd80a
buf: switch to int from bool
author | David Demelier <markand@malikania.fr> |
---|---|
date | Wed, 24 Feb 2021 11:39:26 +0100 |
parents | b1991ee4451d |
children | d87e84936795 |
comparison
equal
deleted
inserted
replaced
20:08a6d4e6012d | 21:939fe74cd80a |
---|---|
20 #include <stdlib.h> | 20 #include <stdlib.h> |
21 #include <string.h> | 21 #include <string.h> |
22 | 22 |
23 #include "buf.h" | 23 #include "buf.h" |
24 | 24 |
25 bool | 25 int |
26 buf_dup(struct buf *b, const struct buf *src) | 26 buf_dup(struct buf *b, const struct buf *src) |
27 { | 27 { |
28 assert(b); | 28 assert(b); |
29 assert(src); | 29 assert(src); |
30 | 30 |
31 if (!src->data) | 31 if (!src->data) |
32 return true; | 32 return 0; |
33 if (!(b->data = BUF_MALLOC(src->length + 1))) | 33 if (!(b->data = BUF_MALLOC(src->length + 1))) |
34 return false; | 34 return -1; |
35 | 35 |
36 strcpy(b->data, src->data); | 36 strcpy(b->data, src->data); |
37 b->capacity = src->length; | 37 b->capacity = src->length; |
38 b->length = src->length; | 38 b->length = src->length; |
39 | 39 |
40 return true; | 40 return 0; |
41 } | 41 } |