From b6bf81e3e971e246d1ed946ccea75aaf5faa8ab8 Mon Sep 17 00:00:00 2001 From: Pedro Date: Tue, 3 Jun 2014 02:09:11 +0800 Subject: [PATCH] Replace -1 ret code --- src/node.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/node.c b/src/node.c index 1d809ed..988eb3e 100644 --- a/src/node.c +++ b/src/node.c @@ -540,7 +540,8 @@ edge * r3_node_find_common_prefix(node *n, char *path, int path_len, int *prefix break; } } else if (ret == -1) { - return -1; + + return NULL; } else { break; } @@ -568,8 +569,11 @@ node * r3_tree_insert_pathl_ex(node *tree, const char *path, int path_len, route /* length of common prefix */ int prefix_len = 0; - e = r3_node_find_common_prefix(tree, path, path_len, &prefix_len, errstr); - if (e == -1) { + char *err = NULL; + e = r3_node_find_common_prefix(tree, path, path_len, &prefix_len, &err); + if (err) { + // copy the error message pointer + if (errstr) *errstr = err; return NULL; }