diff options
author | Kevin P. Fleming <kpfleming@digium.com> | 2005-05-15 23:26:45 +0000 |
---|---|---|
committer | Kevin P. Fleming <kpfleming@digium.com> | 2005-05-15 23:26:45 +0000 |
commit | 9bf21dbf58d65590d989fd66a452eff9e56617f4 (patch) | |
tree | 59f76110ffd03d746a3ba0e86ada2133b17c0a43 /doc | |
parent | eaececc92004e61ef75c936652cf948e560af8f2 (diff) |
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
Diffstat (limited to 'doc')
-rwxr-xr-x | doc/CODING-GUIDELINES | 7 |
1 files changed, 6 insertions, 1 deletions
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. |