aboutsummaryrefslogtreecommitdiffstats
path: root/doc
diff options
context:
space:
mode:
authortilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b>2009-11-26 02:09:58 +0000
committertilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b>2009-11-26 02:09:58 +0000
commit7326fe3151bcb4df8ba96d0254bbf962d81f7d8a (patch)
tree168be570fce1a673532f1eed86f5830fabd01de9 /doc
parent66be8d4964460f01e9eed6e9ba9aa316d7657244 (diff)
Reorder option flags. Change guidelines so that example code is consistent with guidelines
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@231369 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'doc')
-rw-r--r--doc/CODING-GUIDELINES15
1 files changed, 9 insertions, 6 deletions
diff --git a/doc/CODING-GUIDELINES b/doc/CODING-GUIDELINES
index 4261f2013..d1ae32dfe 100644
--- a/doc/CODING-GUIDELINES
+++ b/doc/CODING-GUIDELINES
@@ -435,9 +435,9 @@ functions.
When making applications, always ast_strdupa(data) to a local pointer if you
intend to parse the incoming data string.
- if (data)
+ if (data) {
mydata = ast_strdupa(data);
-
+ }
- Use the argument parsing macros to declare arguments and parse them, i.e.:
@@ -521,10 +521,11 @@ throughout the code to log that this has occurred.
The functions strdup and strndup can *not* accept a NULL argument. This results
in having code like this:
- if (str)
+ if (str) {
newstr = strdup(str);
- else
+ } else {
newstr = NULL;
+ }
However, the ast_strdup and ast_strdupa functions will happily accept a NULL
argument without generating an error. The same code can be written as:
@@ -666,8 +667,9 @@ const char *postfix = "post";
char *newname;
char *name = "data";
-if (name && (newname = alloca(strlen(name) + strlen(prefix) + strlen(postfix) + 3)))
+if (name && (newname = alloca(strlen(name) + strlen(prefix) + strlen(postfix) + 3))) {
snprintf(newname, strlen(name) + strlen(prefix) + strlen(postfix) + 3, "%s/%s/%s", prefix, name, postfix);
+|
...vs this alternative:
@@ -677,8 +679,9 @@ char *newname;
char *name = "data";
int len = 0;
-if (name && (len = strlen(name) + strlen(prefix) + strlen(postfix) + 3) && (newname = alloca(len)))
+if (name && (len = strlen(name) + strlen(prefix) + strlen(postfix) + 3) && (newname = alloca(len))) {
snprintf(newname, len, "%s/%s/%s", prefix, name, postfix);
+}
* Creating new manager events?
------------------------------