[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bug-patch] strndup/strnlen problems with 2.6.1
From: |
Jim Reid |
Subject: |
[bug-patch] strndup/strnlen problems with 2.6.1 |
Date: |
Mon, 5 Apr 2010 16:32:10 +0100 |
I've found a solution to the strndup/strnlen problems. The code in gl/
lib/strndup.c seems remarkably clumsy because the call to strnlen() is
pointless. strndup is already defining the upper bound on the memory
allocation, so you might as well just use that. The declaration of
strnlen() also needs to be commented out.
char *
strndup (char const *s, size_t n)
{
/* size_t len = strnlen (s, n);*/
size_t len = n;
char *new = malloc (len + 1);
if (new == NULL)
return NULL;
new[len] = '\0';
return memcpy (new, s, len);
}
BTW, the Makefile reference to a variable called transform does
nothing apart from a no-op invocation of sed.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [bug-patch] strndup/strnlen problems with 2.6.1,
Jim Reid <=