lkml.org 
[lkml]   [2014]   [Oct]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Subject[PATCH v2] lib: string.c: Added a funktion function strzcpy
Date
I've added a strzcpy to make it easier to not do wrong
when you use the function strncpy.

Often one needs the zero padding, but must still have a
guaranteed zero character terminat.
Then you end up writing code like this:
strncpy(to, src, sizeof(to));
to[sizeof(to) - 1] = '\0';

This is solved with strzcpy.

Rickard Strandqvist (1):
lib: string.c: Added a funktion function strzcpy

include/linux/string.h | 1 +
lib/string.c | 31 +++++++++++++++++++++++++++++++
2 files changed, 32 insertions(+)

--
1.7.10.4



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