Remove now unused patch -- we have strndup(3).

No bump because because code was #ifndef HAVE_STRNDUP ... so it wasn't
picked up anymore.
This commit is contained in:
ajacoutot 2010-06-16 12:22:45 +00:00
parent 5d22cfc900
commit 999d79d16b

View File

@ -1,39 +0,0 @@
$OpenBSD: patch-src_softmagic_c,v 1.4 2009/04/04 18:28:15 rui Exp $
--- src/softmagic.c.orig Fri Nov 7 22:50:37 2008
+++ src/softmagic.c Sat Mar 28 13:22:45 2009
@@ -331,21 +331,26 @@ check_fmt(struct magic_set *ms, struct magic *m)
#ifndef HAVE_STRNDUP
char * strndup(const char *, size_t);
+size_t strnlen (const char *, size_t);
+size_t
+strnlen (const char *string, size_t maxlen)
+{
+ const char *end = memchr (string, '\0', maxlen);
+ return end ? (size_t) (end - string) : maxlen;
+}
+
char *
strndup(const char *str, size_t n)
{
- size_t len;
- char *copy;
+ size_t len = strnlen (str, n);
+ char *copy = malloc (len + 1);
- len = strlen(str);
- if (len > n)
- len = n;
- if (!(copy = malloc(len + 1)))
- return (NULL);
- (void) memcpy(copy, str, len + 1);
+ if (copy == NULL)
+ return NULL;
+
copy[len] = '\0';
- return (copy);
+ return memcpy (copy, str, len);
}
#endif /* HAVE_STRNDUP */