From: Florian Forster Date: Wed, 5 Mar 2008 08:27:28 +0000 (+0100) Subject: src/common.[ch]: Changed the signature of `sstrncpy' to match that of `strncpy'. X-Git-Tag: collectd-4.3.1~3 X-Git-Url: https://git.octo.it/?a=commitdiff_plain;h=629d39950376577fe33c0ff328efd2e7449ada60;p=collectd.git src/common.[ch]: Changed the signature of `sstrncpy' to match that of `strncpy'. --- diff --git a/src/common.c b/src/common.c index 3489e8d5..a2c4794d 100644 --- a/src/common.c +++ b/src/common.c @@ -52,11 +52,13 @@ static pthread_mutex_t getpwnam_r_lock = PTHREAD_MUTEX_INITIALIZER; static pthread_mutex_t strerror_r_lock = PTHREAD_MUTEX_INITIALIZER; #endif -void sstrncpy (char *d, const char *s, int len) +char *sstrncpy (char *dest, const char *src, size_t n) { - strncpy (d, s, len); - d[len - 1] = '\0'; -} + strncpy (dest, src, n); + dest[n - 1] = '\0'; + + return (dest); +} /* char *sstrncpy */ char *sstrdup (const char *s) { diff --git a/src/common.h b/src/common.h index 8e0d8404..e99aea69 100644 --- a/src/common.h +++ b/src/common.h @@ -38,7 +38,7 @@ #define STATIC_ARRAY_SIZE(a) (sizeof (a) / sizeof (*(a))) -void sstrncpy(char *d, const char *s, int len); +char *sstrncpy (char *dest, const char *src, size_t n); char *sstrdup(const char *s); void *smalloc(size_t size); char *sstrerror (int errnum, char *buf, size_t buflen);