Don't build code like this:
if (foo) {
Don't build code like this:
if (foo) {
- .... 50 lines of code ...
+ /* .... 50 lines of code ... */
}
Instead, try to minimize the number of lines of code that need to be
}
Instead, try to minimize the number of lines of code that need to be
statement, like so:
if !(foo) {
statement, like so:
if !(foo) {
}
.... 50 lines of code ....
}
.... 50 lines of code ....
When making applications, always ast_strdupa(data) to a local pointer if
you intend to parse it.
When making applications, always ast_strdupa(data) to a local pointer if
you intend to parse it.
- if(data)
- mydata = ast_strdupa(data);
+
+ if (data)
+ mydata = ast_strdupa(data);
Always derefrence or localize pointers to things that are not yours like
channel members in a channel that is not associated with the current
thread and for which you do not have a lock.
Always derefrence or localize pointers to things that are not yours like
channel members in a channel that is not associated with the current
thread and for which you do not have a lock.
- channame = ast_strdupa(otherchan->name);
+ channame = ast_strdupa(otherchan->name);
If you do the same or a similar operation more than 1 time, make it a
function or macro.
If you do the same or a similar operation more than 1 time, make it a
function or macro.
tmp = malloc(sizeof(*tmp));
if (tmp)
tmp = malloc(sizeof(*tmp));
if (tmp)
- memset(tmp, 0, sizeof(*tmp));
+ memset(tmp, 0, sizeof(*tmp));
This eliminates duplication of the 'struct foo' identifier, which makes the
code easier to read and also ensures that if it is copy-and-pasted it won't
This eliminates duplication of the 'struct foo' identifier, which makes the
code easier to read and also ensures that if it is copy-and-pasted it won't