[asterisk-commits] mmichelson: branch mmichelson/npm_fixes r181020 - /team/mmichelson/npm_fixes/...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Tue Mar 10 18:25:19 CDT 2009
Author: mmichelson
Date: Tue Mar 10 18:25:14 2009
New Revision: 181020
URL: http://svn.digium.com/svn-view/asterisk?view=rev&rev=181020
Log:
Handle allocation failure and correct indentation level of a function.
Modified:
team/mmichelson/npm_fixes/main/pbx.c
Modified: team/mmichelson/npm_fixes/main/pbx.c
URL: http://svn.digium.com/svn-view/asterisk/team/mmichelson/npm_fixes/main/pbx.c?view=diff&rev=181020&r1=181019&r2=181020
==============================================================================
--- team/mmichelson/npm_fixes/main/pbx.c (original)
+++ team/mmichelson/npm_fixes/main/pbx.c Tue Mar 10 18:25:14 2009
@@ -1797,29 +1797,31 @@
sorted in increasing value as you go to the leaves */
if (!(*parent_ptr)) {
*parent_ptr = node;
- } else {
- if ((*parent_ptr)->specificity > node->specificity){
- /* insert at head */
- node->alt_char = (*parent_ptr);
- *parent_ptr = node;
- } else {
- lcurr = *parent_ptr;
- for (curr=(*parent_ptr)->alt_char; curr; curr = curr->alt_char) {
- if (curr->specificity > node->specificity) {
- node->alt_char = curr;
- lcurr->alt_char = node;
- break;
- }
- lcurr = curr;
- }
- if (!curr) {
- lcurr->alt_char = node;
- }
- }
- }
-}
-
-
+ return;
+ }
+
+ if ((*parent_ptr)->specificity > node->specificity){
+ /* insert at head */
+ node->alt_char = (*parent_ptr);
+ *parent_ptr = node;
+ return;
+ }
+
+ lcurr = *parent_ptr;
+ for (curr=(*parent_ptr)->alt_char; curr; curr = curr->alt_char) {
+ if (curr->specificity > node->specificity) {
+ node->alt_char = curr;
+ lcurr->alt_char = node;
+ break;
+ }
+ lcurr = curr;
+ }
+
+ if (!curr) {
+ lcurr->alt_char = node;
+ }
+
+}
static struct match_char *add_pattern_node(struct ast_context *con, struct match_char *current, char *pattern, int is_pattern, int already, int specificity, struct match_char **nextcharptr)
{
@@ -1975,20 +1977,11 @@
} else {
if (findonly)
return m1;
- m1 = add_pattern_node(con, m1, buf, pattern, already,specif, m0); /* m1 is the node just added */
- /* XXX We should be sure to make sure that m1 is non-NULL here
- */
+ if (!(m1 = add_pattern_node(con, m1, buf, pattern, already,specif, m0))) { /* m1 is the node just added */
+ return NULL;
+ }
m0 = &m1->next_char;
}
-
- /* XXX MCM - This specifically sees if we have reached the end of the
- * exten we are parsing. If so, then set m1->exten to e1. Note that if this
- * is an exact duplicate of an already existing pattern, then we are overwriting
- * m2->exten here and so the old ast_exten will not be reachable in the trie. We do
- * not print any sort of warning about this, and I think we should. Also, it would
- * be a smart idea to make sure that m1 is non-NULL here since add_pattern_node could
- * return NULL.
- */
if (!(*(s1+1))) {
if (m2) {
ast_log(LOG_WARNING, "Found duplicate exten. Had %s found %s\n", m2->exten->exten, e1->exten);
More information about the asterisk-commits
mailing list