From 2aa3509845f5a3385dc26837592805c1dd7da479 Mon Sep 17 00:00:00 2001 From: c9s Date: Tue, 3 Jun 2014 22:15:59 +0800 Subject: [PATCH] Add more const --- src/node.c | 4 +++- src/slug.c | 2 +- src/slug.h | 8 ++++---- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/node.c b/src/node.c index 678231a..956ae82 100644 --- a/src/node.c +++ b/src/node.c @@ -28,6 +28,7 @@ static int strndiff(char * d1, char * d2, unsigned int n) { return d1 - o; } +/* static int strdiff(char * d1, char * d2) { char * o = d1; while( *d1 == *d2 ) { @@ -36,6 +37,7 @@ static int strdiff(char * d1, char * d2) { } return d1 - o; } +*/ /** @@ -530,7 +532,7 @@ edge * r3_node_find_common_prefix(node *n, const char *path, int path_len, int * } else if ( p < slug->begin ) { break; } else if ( p >= slug->end && p < (path + path_len) ) { - offset = slug->end + 1; + offset = (char*) slug->end + 1; prefix = p - path; continue; } else { diff --git a/src/slug.c b/src/slug.c index 4edbead..cd62b16 100644 --- a/src/slug.c +++ b/src/slug.c @@ -91,7 +91,7 @@ int r3_slug_parse(r3_slug_t *s, const char *needle, int needle_len, char *offset int cnt = 0; int state = 0; - char * p = offset; + const char * p = offset; while( (p-needle) < needle_len) { // escape one character diff --git a/src/slug.h b/src/slug.h index cd51700..14db6c2 100644 --- a/src/slug.h +++ b/src/slug.h @@ -11,19 +11,19 @@ typedef struct { /** * source path */ - char * path; + const char * path; int path_len; /** * slug start pointer */ - char * begin; + const char * begin; /** * slug end pointer */ - char * end; + const char * end; /** * slug length @@ -31,7 +31,7 @@ typedef struct { int len; // slug pattern pointer if we have one - char * pattern; + const char * pattern; // the length of custom pattern, if the pattern is found. int pattern_len;