From 9bf21dbf58d65590d989fd66a452eff9e56617f4 Mon Sep 17 00:00:00 2001 From: "Kevin P. Fleming" Date: Sun, 15 May 2005 23:26:45 +0000 Subject: more strncpy -> ast_copy_string conversions, fixing some buglets along the way add recommendation to CODING-GUIDELINES to use ast_copy_string instead of strncpy in new code git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@5686 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- doc/CODING-GUIDELINES | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'doc') diff --git a/doc/CODING-GUIDELINES b/doc/CODING-GUIDELINES index f4eb9a19b..41147fb5a 100755 --- a/doc/CODING-GUIDELINES +++ b/doc/CODING-GUIDELINES @@ -164,6 +164,11 @@ if (name && (len = strlen(name) + strlen(prefix) + strlen(postfix) + 3) && (newn Use const on pointers which your function will not be modifying, as this allows the compiler to make certain optimizations. +Don't use strncpy for copying whole strings; it does not guarantee that the +output buffer will be null-terminated. Use ast_copy_string instead, which +is also slightly more efficient (and allows passing the actual buffer +size, which makes the code clearer). + == CLI Commands == New CLI commands should be named using the module's name, followed by a verb @@ -190,5 +195,5 @@ Applications are registered and invoked using the ast_register_application function; see the apps/app_skel.c file for an example. -Functions are registered using 'struct ast_custom_function_obj' +Functions are registered using 'struct ast_custom_function' structures and the ast_custom_function_register function. -- cgit v1.2.3