From 629d39950376577fe33c0ff328efd2e7449ada60 Mon Sep 17 00:00:00 2001 From: Florian Forster Date: Wed, 5 Mar 2008 09:27:28 +0100 Subject: [PATCH] src/common.[ch]: Changed the signature of `sstrncpy' to match that of `strncpy'. --- src/common.c | 10 ++++++---- src/common.h | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) 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); -- 2.11.0