[PATCH 5/5] Convert ProcRenderQueryFilters to use memcpy instead of strncpy

Alan Coopersmith alan.coopersmith at oracle.com
Fri Oct 28 21:41:53 PDT 2011


We just got the string length with strlen, might as well use it
to copy the whole string quickly instead of checking each character
a second time to see if it's 0 or not.

Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>
---
 render/render.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/render/render.c b/render/render.c
index ff75409..d82e099 100644
--- a/render/render.c
+++ b/render/render.c
@@ -1800,7 +1800,7 @@ ProcRenderQueryFilters (ClientPtr client)
 	{
 	    j = strlen (ps->filters[i].name);
 	    *names++ = j;
-	    strncpy (names, ps->filters[i].name, j);
+	    memcpy (names, ps->filters[i].name, j);
 	    names += j;
 	}
 	
@@ -1809,7 +1809,7 @@ ProcRenderQueryFilters (ClientPtr client)
 	{
 	    j = strlen (ps->filterAliases[i].alias);
 	    *names++ = j;
-	    strncpy (names, ps->filterAliases[i].alias, j);
+	    memcpy (names, ps->filterAliases[i].alias, j);
 	    names += j;
 	}
     }
-- 
1.7.3.2



More information about the xorg-devel mailing list