move static/stub version of dladdr out of dynlink.c
[musl] / src / string / strlcpy.c
index bbebf1d..193d724 100644 (file)
@@ -1,5 +1,5 @@
+#define _BSD_SOURCE
 #include <string.h>
-#include <stdlib.h>
 #include <stdint.h>
 #include <limits.h>
 #include "libc.h"
@@ -16,12 +16,12 @@ size_t strlcpy(char *d, const char *s, size_t n)
        const size_t *ws;
 
        if (!n--) goto finish;
-       if (((uintptr_t)s & ALIGN) != ((uintptr_t)d & ALIGN)) {
+       if (((uintptr_t)s & ALIGN) == ((uintptr_t)d & ALIGN)) {
                for (; ((uintptr_t)s & ALIGN) && n && (*d=*s); n--, s++, d++);
                if (n && *s) {
                        wd=(void *)d; ws=(const void *)s;
                        for (; n>=sizeof(size_t) && !HASZERO(*ws);
-                              n-=sizeof(size_t), ws++, *wd++) *wd = *ws;
+                              n-=sizeof(size_t), ws++, wd++) *wd = *ws;
                        d=(void *)wd; s=(const void *)ws;
                }
        }