From 45690da3dcf520e1c174a16c45075ed81995454c Mon Sep 17 00:00:00 2001 From: c9s Date: Wed, 21 May 2014 22:05:10 +0800 Subject: [PATCH 1/2] found flag for slug char --- src/str.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/str.c b/src/str.c index 673eee4..581cf63 100644 --- a/src/str.c +++ b/src/str.c @@ -41,8 +41,12 @@ char * inside_slug(char * needle, int needle_len, char *offset) { char * s1 = offset; char * s2 = offset; + short found_s1 = 0; + short found_s2 = 0; + while( s1 >= needle && (s1 - needle < needle_len) ) { if ( *s1 == '{' ) { + found_s1 = 1; break; } s1--; @@ -51,12 +55,12 @@ char * inside_slug(char * needle, int needle_len, char *offset) { char * end = needle + needle_len; while( (s2 + 1) < end ) { if ( *s2 == '}' ) { + found_s2 = 1; break; } s2++; } - - if ( *s1 == '{' && *s2 == '}' ) { + if (found_s1 && found_s2) { return s1; } return NULL; From f6d2502896886f5d7c15e7cd8f7814aeb6244fcb Mon Sep 17 00:00:00 2001 From: c9s Date: Wed, 21 May 2014 22:08:25 +0800 Subject: [PATCH 2/2] include jemalloc.h --- src/zmalloc.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/zmalloc.c b/src/zmalloc.c index 72447d8..fad1c2b 100644 --- a/src/zmalloc.c +++ b/src/zmalloc.c @@ -61,6 +61,7 @@ void zlibc_free(void *ptr) { #define realloc(ptr,size) tc_realloc(ptr,size) #define free(ptr) tc_free(ptr) #elif defined(USE_JEMALLOC) +#include #define malloc(size) je_malloc(size) #define calloc(count,size) je_calloc(count,size) #define realloc(ptr,size) je_realloc(ptr,size)