Improve comments for strlcat() and strlcpy().

This commit is contained in:
Dag-Erling Smørgrav 2017-04-28 21:33:10 +02:00
parent d4ae7a43cb
commit d80dc09f3c
2 changed files with 15 additions and 4 deletions

View file

@ -1,5 +1,5 @@
/*- /*-
* Copyright (c) 2011-2014 Dag-Erling Smørgrav * Copyright (c) 2011-2017 Dag-Erling Smørgrav
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -33,7 +33,13 @@
#include <cryb/strlcat.h> #include <cryb/strlcat.h>
/* like strcat(3), but always NUL-terminates; returns strlen(src) */ /*
* Like strcat(3), but always NUL-terminates.
*
* Returns strlen(dst) + strlen(src), regardless of how much was copied,
* if dst was properly terminated. Returns size + strlen(src) otherwise.
*/
size_t size_t
cryb_strlcat(char *dst, const char *src, size_t size) cryb_strlcat(char *dst, const char *src, size_t size)
{ {

View file

@ -1,5 +1,5 @@
/*- /*-
* Copyright (c) 2011-2014 Dag-Erling Smørgrav * Copyright (c) 2011-2017 Dag-Erling Smørgrav
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -33,7 +33,12 @@
#include <cryb/strlcpy.h> #include <cryb/strlcpy.h>
/* like strcpy(3), but always NUL-terminates; returns strlen(src) */ /*
* Like strcpy(3), but always NUL-terminates.
*
* Returns strlen(src), regardless of how much was copied.
*/
size_t size_t
cryb_strlcpy(char *dst, const char *src, size_t size) cryb_strlcpy(char *dst, const char *src, size_t size)
{ {