Add const for pointers

This commit is contained in:
c9s 2014-05-28 21:00:02 +08:00
parent 34ec73ecbc
commit f5996731ca
2 changed files with 9 additions and 9 deletions

View file

@ -96,7 +96,7 @@ struct _edge {
typedef struct {
str_array * vars;
char * path; // current path to dispatch
const char * path; // current path to dispatch
int path_len; // the length of the current path
int request_method; // current request method
@ -165,7 +165,7 @@ void r3_tree_compile(node *n);
void r3_tree_compile_patterns(node * n);
node * r3_tree_matchl(const node * n, const char * path, int path_len, match_entry * entry);
node * r3_tree_matchl(const node * n, const char * path, int path_len, const match_entry * entry);
#define r3_tree_match(n,p,e) r3_tree_matchl(n,p, strlen(p), e)
@ -182,7 +182,7 @@ void r3_edge_free(edge * edge);
match_entry * match_entry_createl(char * path, int path_len);
match_entry * match_entry_createl(const char * path, int path_len);
#define match_entry_create(path) match_entry_createl(path,strlen(path))
@ -193,13 +193,13 @@ route * r3_route_create(const char * path);
route * r3_route_createl(const char * path, int path_len);
int r3_route_cmp(route *r1, match_entry *r2);
int r3_route_cmp(route *r1, const match_entry *r2);
void r3_node_append_route(node * n, route * route);
void r3_route_free(route * route);
route * r3_tree_match_route(const node *n, match_entry * entry);
route * r3_tree_match_route(const node *n, const match_entry * entry);
#define METHOD_GET 2
#define METHOD_POST 2<<1

View file

@ -223,7 +223,7 @@ void r3_tree_compile_patterns(node * n) {
}
match_entry * match_entry_createl(char * path, int path_len) {
match_entry * match_entry_createl(const char * path, int path_len) {
match_entry * entry = zmalloc(sizeof(match_entry));
if(!entry)
return NULL;
@ -251,7 +251,7 @@ void match_entry_free(match_entry * entry) {
* @param int path_len the length of the URL path.
* @param match_entry* entry match_entry is used for saving the captured dynamic strings from pcre result.
*/
node * r3_tree_matchl(const node * n, const char * path, int path_len, match_entry * entry) {
node * r3_tree_matchl(const node * n, const char * path, int path_len, const match_entry * entry) {
info("try matching: %s\n", path);
edge *e;
@ -374,7 +374,7 @@ node * r3_tree_matchl(const node * n, const char * path, int path_len, match_ent
route * r3_tree_match_route(const node *tree, match_entry * entry) {
route * r3_tree_match_route(const node *tree, const match_entry * entry) {
node *n;
n = r3_tree_match_entry(tree, entry);
if (n->routes && n->route_len > 0) {
@ -655,7 +655,7 @@ void r3_tree_dump(const node * n, int level) {
*
* -1 == different route
*/
int r3_route_cmp(route *r1, match_entry *r2) {
int r3_route_cmp(route *r1, const match_entry *r2) {
if (r1->request_method != 0) {
if (0 == (r1->request_method & r2->request_method) ) {
return -1;