From 4d68ae68416c632547ee1cb5e0a7f71c844bbf10 Mon Sep 17 00:00:00 2001 From: c9s Date: Wed, 4 Jun 2014 13:45:28 +0800 Subject: [PATCH] remove const from errstr --- include/r3.h | 6 +++--- src/node.c | 8 ++++---- src/slug.c | 4 ++-- src/slug.h | 4 ++-- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/include/r3.h b/include/r3.h index 66f2207..8334a49 100644 --- a/include/r3.h +++ b/include/r3.h @@ -122,13 +122,13 @@ edge * r3_node_find_edge(const node * n, const char * pat, int pat_len); void r3_node_append_edge(node *n, edge *child); -edge * r3_node_find_common_prefix(node *n, const char *path, int path_len, int *prefix_len, const char **errstr); +edge * r3_node_find_common_prefix(node *n, const char *path, int path_len, int *prefix_len, char **errstr); node * r3_tree_insert_pathl(node *tree, const char *path, int path_len, void * data); route * r3_tree_insert_routel(node *tree, int method, const char *path, int path_len, void *data); -route * r3_tree_insert_routel_ex(node *tree, int method, const char *path, int path_len, void *data, const char **errstr); +route * r3_tree_insert_routel_ex(node *tree, int method, const char *path, int path_len, void *data, char **errstr); #define r3_tree_insert_routel(n, method, path, path_len, data) r3_tree_insert_routel_ex(n, method, path, path_len, data, NULL) @@ -140,7 +140,7 @@ route * r3_tree_insert_routel_ex(node *tree, int method, const char *path, int p /** * The private API to insert a path */ -node * r3_tree_insert_pathl_ex(node *tree, const char *path, int path_len, route * route, void * data, const char ** errstr); +node * r3_tree_insert_pathl_ex(node *tree, const char *path, int path_len, route * route, void * data, char ** errstr); void r3_tree_dump(const node * n, int level); diff --git a/src/node.c b/src/node.c index 259ce29..97c40a2 100644 --- a/src/node.c +++ b/src/node.c @@ -473,7 +473,7 @@ route * r3_route_createl(const char * path, int path_len) { * * method (int): METHOD_GET, METHOD_POST, METHOD_PUT, METHOD_DELETE ... */ -route * r3_tree_insert_routel_ex(node *tree, int method, const char *path, int path_len, void *data, const char **errstr) { +route * r3_tree_insert_routel_ex(node *tree, int method, const char *path, int path_len, void *data, char **errstr) { route *r = r3_route_createl(path, path_len); CHECK_PTR(r); r->request_method = method; // ALLOW GET OR POST METHOD @@ -506,7 +506,7 @@ node * r3_tree_insert_pathl(node *tree, const char *path, int path_len, void * d * 4. "aaa{slug:xxx}/hate" vs "aab{slug:yyy}/bar" => common prefix = "aa" * 5. "/foo/{slug}/hate" vs "/fo{slug}/bar" => common prefix = "/fo" */ -edge * r3_node_find_common_prefix(node *n, const char *path, int path_len, int *prefix_len, const char **errstr) { +edge * r3_node_find_common_prefix(node *n, const char *path, int path_len, int *prefix_len, char **errstr) { int i = 0; int prefix = 0; *prefix_len = 0; @@ -567,7 +567,7 @@ edge * r3_node_find_common_prefix(node *n, const char *path, int path_len, int * /** * Return the last inserted node. */ -node * r3_tree_insert_pathl_ex(node *tree, const char *path, int path_len, route * route, void * data, const char **errstr) +node * r3_tree_insert_pathl_ex(node *tree, const char *path, int path_len, route * route, void * data, char **errstr) { node * n = tree; @@ -578,7 +578,7 @@ node * r3_tree_insert_pathl_ex(node *tree, const char *path, int path_len, route /* length of common prefix */ int prefix_len = 0; - const char *err = NULL; + char *err = NULL; e = r3_node_find_common_prefix(tree, path, path_len, &prefix_len, &err); if (err) { // copy the error message pointer diff --git a/src/slug.c b/src/slug.c index bb07cbb..7990fc9 100644 --- a/src/slug.c +++ b/src/slug.c @@ -76,7 +76,7 @@ Return 1 => Slug found Return -1 => Slug parsing error */ -int r3_slug_parse(r3_slug_t *s, const char *needle, int needle_len, const char *offset, const char **errstr) { +int r3_slug_parse(r3_slug_t *s, const char *needle, int needle_len, const char *offset, char **errstr) { s->path = (char*) needle; s->path_len = needle_len; @@ -152,7 +152,7 @@ int r3_slug_parse(r3_slug_t *s, const char *needle, int needle_len, const char * /** * provide a quick way to count slugs, simply search for '{' */ -int slug_count(const char * needle, int len, const char **errstr) { +int slug_count(const char * needle, int len, char **errstr) { int cnt = 0; int state = 0; char * p = (char*) needle; diff --git a/src/slug.h b/src/slug.h index e7b7618..7511125 100644 --- a/src/slug.h +++ b/src/slug.h @@ -43,13 +43,13 @@ r3_slug_t * r3_slug_new(const char * path, int path_len); int r3_slug_check(r3_slug_t *s); -int r3_slug_parse(r3_slug_t *s, const char *needle, int needle_len, const char *offset, const char **errstr); +int r3_slug_parse(r3_slug_t *s, const char *needle, int needle_len, const char *offset, char **errstr); char * r3_slug_to_str(const r3_slug_t *s); void r3_slug_free(r3_slug_t * s); -int slug_count(const char * needle, int len, const char **errstr); +int slug_count(const char * needle, int len, char **errstr); static inline int r3_path_contains_slug_char(const char * str) { return strchr(str, '{') != NULL ? 1 : 0;