use 64 * 3 bytes instead of 220 bytes for combined pattern

This commit is contained in:
c9s 2015-11-10 19:56:07 +08:00
parent fbe3fb66b1
commit c18c466a9b
2 changed files with 10 additions and 10 deletions

View file

@ -623,3 +623,5 @@
1447155699,13781189.15,5851252.25,62601.55,2539751.33 1447155699,13781189.15,5851252.25,62601.55,2539751.33
1447156053,13415522.24,5930072.07,82241.25,2533834.67 1447156053,13415522.24,5930072.07,82241.25,2533834.67
1447156073,13492327.24,5848589.68,52428.80,2567896.99 1447156073,13492327.24,5848589.68,52428.80,2567896.99
1447156411,13229275.90,5858750.37,66576.25,2523350.73
1447156432,13556025.90,5873947.56,62601.55,2487130.01

Can't render this file because it has a wrong number of fields in line 447.

View file

@ -173,26 +173,24 @@ int r3_tree_compile(node *n, char **errstr)
* Return 0 if success * Return 0 if success
*/ */
int r3_tree_compile_patterns(node * n, char **errstr) { int r3_tree_compile_patterns(node * n, char **errstr) {
char * cpat; edge * e = NULL;
char * p; char * p;
char * cpat = zcalloc(sizeof(char) * 64 * 3); // XXX
cpat = zcalloc(sizeof(char) * 220); // XXX
if (!cpat) { if (!cpat) {
asprintf(errstr, "Can not allocate memory"); asprintf(errstr, "Can not allocate memory");
return -1; return -1;
} }
p = cpat; p = cpat;
int opcode_cnt = 0;
edge *e = NULL; int i = 0;
int opcode_cnt = 0; for (; i < n->edge_len ; i++) {
for ( int i = 0 ; i < n->edge_len ; i++ ) {
e = n->edges[i]; e = n->edges[i];
if (e->opcode) {
if ( e->opcode )
opcode_cnt++; opcode_cnt++;
}
if ( e->has_slug ) { if (e->has_slug) {
// compile "foo/{slug}" to "foo/[^/]+" // compile "foo/{slug}" to "foo/[^/]+"
char * slug_pat = r3_slug_compile(e->pattern, e->pattern_len); char * slug_pat = r3_slug_compile(e->pattern, e->pattern_len);
strcat(p, slug_pat); strcat(p, slug_pat);