lkml.org 
[lkml]   [2014]   [Oct]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] lib: string.c: A speed optimized for strncpy
On Sun, Oct 05, 2014 at 06:01:43PM +0200, Rickard Strandqvist wrote:
> Hi
>
> Yes, it can be faster, even if it is as you say, probably a difference
> depending on the size of the count.
> And even greater need to test this on a variety of hardware :-/

Most architectures (the notable exception is ARM) have an their own
optimized strncpy() function. Probably strzcpy() should just call it.

char *strzcpy(char *dest, const char *src, size_t count)
{
strncpy(dest, src, count);
if (count)
dest[count - 1] = '\0';
return dest;
}

regards,
dan carpenter



\
 
 \ /
  Last update: 2014-10-15 14:01    [W:0.051 / U:0.204 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site