links

lynx-like text mode web browser
git clone anongit@rnpnr.xyz:links.git
Log | Files | Refs | Feed | README | LICENSE

Commit: bc4e7359dc05f1692352cb9c07d649e282884ce1
Parent: 176f012195394294d52f9ca645affac0ea5fe5f7
Author: Randy Palamar
Date:   Tue, 29 Nov 2022 22:46:04 -0700

string.c: always add extra byte to str

this means the caller only needs to keep track of the text
length. i.e. the length will be the same as what strlen returns.

Diffstat:
Mstring.c | 6+-----
1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/string.c b/string.c @@ -105,11 +105,7 @@ add_bytes_to_str(unsigned char **s, int *l, unsigned char *a, size_t ll) *l = *l + ll; - /* FIXME: Hack, behaves like init_str() fn */ - if (ol == 0) - p = xreallocarray(p, *l + 1, sizeof(unsigned char)); - else - p = xreallocarray(p, *l, sizeof(unsigned char)); + p = xreallocarray(p, *l + 1, sizeof(unsigned char)); p[*l] = 0; memcpy(p + ol, a, ll);