From owner-freebsd-audit Thu Jan 24 13:48:45 2002 Delivered-To: freebsd-audit@freebsd.org Received: from xerxes.courtesan.com (courtesan.com [206.168.103.86]) by hub.freebsd.org (Postfix) with ESMTP id 60C9637B41C; Thu, 24 Jan 2002 13:48:37 -0800 (PST) Received: from xerxes.courtesan.com (IDENT:millert@localhost.courtesan.com [127.0.0.1]) by xerxes.courtesan.com (8.12.2/8.12.1) with ESMTP id g0OLmHJi006634; Thu, 24 Jan 2002 14:48:17 -0700 (MST) Message-Id: <200201242148.g0OLmHJi006634@xerxes.courtesan.com> To: "Andrew R. Reiter" Cc: "Andrey A. Chernov" , Alexey Zelkin , audit@FreeBSD.ORG Subject: Re: CFR: strncpy -> strlcpy in setlocale() In-reply-to: Your message of "Thu, 24 Jan 2002 16:42:30 EST." References: Date: Thu, 24 Jan 2002 14:48:17 -0700 From: "Todd C. Miller" Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG In message so spake "Andrew R. Reiter" (arr): > I know strlcpy() makes more sense than strncpy(), but is there any > difference in terms of speed? This being said, if strlcpy() is slower and > the strncpy() usage is correct, is there really a need for a change? I > guess readability and possible future mistakes in usage are a bonus for > strlcpy. strlcpy() is generally faster since strncpy() does NUL fill and so will also write "len" bytes even when the source string is much smaller. - todd To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message