From 8ba123061094b710221809d36a1a0398ff5e69a4 Mon Sep 17 00:00:00 2001 From: c9s Date: Mon, 19 May 2014 10:49:47 +0800 Subject: [PATCH] Add endpoint check --- src/node.c | 8 +++++++- tests/bench_str.csv | 1 + 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/node.c b/src/node.c index d4963f4..8d112ed 100644 --- a/src/node.c +++ b/src/node.c @@ -453,7 +453,13 @@ node * _r3_tree_insert_pathl(node *tree, char *path, int path_len, route * route if ( subpath_len > 0 ) { return _r3_tree_insert_pathl(e->child, subpath, subpath_len, route, data); } else { - // no more path to insert + // there are no more path to insert + + // see if there is an endpoint already + if (e->child->endpoint) { + // XXX: return an error code instead of NULL + return NULL; + } e->child->endpoint++; // make it as an endpoint e->child->data = data; if (route) { diff --git a/tests/bench_str.csv b/tests/bench_str.csv index 1d50e1c..4d839d1 100644 --- a/tests/bench_str.csv +++ b/tests/bench_str.csv @@ -328,3 +328,4 @@ 1400466833,13166545.46 1400466875,13515485.94 1400467139,13047096.38 +1400467481,13594764.91