summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 9ebb82b)
raw | patch | inline | side by side (parent: 9ebb82b)
author | Florian Forster <octo@noris.net> | |
Wed, 5 Mar 2008 08:27:28 +0000 (09:27 +0100) | ||
committer | Florian Forster <octo@noris.net> | |
Wed, 5 Mar 2008 08:27:28 +0000 (09:27 +0100) |
src/common.c | patch | blob | history | |
src/common.h | patch | blob | history |
diff --git a/src/common.c b/src/common.c
index 3489e8d55bf4cad23a0cf7898aa96c2591d6e234..a2c4794d6d4642dfd2da75eef7747e87849904ca 100644 (file)
--- a/src/common.c
+++ b/src/common.c
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 8e0d8404b5b1cf6c660fb641c4377d4b53584943..e99aea697e45f854b30a50d0b089b8cf20ddf406 100644 (file)
--- a/src/common.h
+++ b/src/common.h
#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);