src/server/daemon/location.c

changeset 650
3e4f9cdd70b8
parent 644
e96e92e3508f
child 651
ed74879c7041
equal deleted inserted replaced
649:3887fd7e8bd7 650:3e4f9cdd70b8
87 } 87 }
88 88
89 return 0; 89 return 0;
90 } 90 }
91 91
92
93 static void location_free_regex(WSLocation *loc) {
94 regfree(&loc->regex);
95 }
92 96
93 WSLocation* cfg_location_get(ServerConfiguration *cfg, ConfigNode *obj) { 97 WSLocation* cfg_location_get(ServerConfiguration *cfg, ConfigNode *obj) {
94 const CxAllocator *a = cfg->a; 98 const CxAllocator *a = cfg->a;
95 99
96 WSLocationMatch match = WS_LOCATION_MATCH_EXACT; 100 WSLocationMatch match = WS_LOCATION_MATCH_EXACT;
132 if(match == WS_LOCATION_MATCH_CS_REGEX || match == WS_LOCATION_MATCH_CI_REGEX) { 136 if(match == WS_LOCATION_MATCH_CS_REGEX || match == WS_LOCATION_MATCH_CI_REGEX) {
133 if(regcomp(&location->regex, match_str.ptr, regex_flags)) { 137 if(regcomp(&location->regex, match_str.ptr, regex_flags)) {
134 log_ereport(LOG_FAILURE, "Location: cannot compile regex pattern %s", match_str.ptr); 138 log_ereport(LOG_FAILURE, "Location: cannot compile regex pattern %s", match_str.ptr);
135 return NULL; 139 return NULL;
136 } 140 }
141 ScfgDestr destr;
142 destr.destr = (cx_destructor_func)location_free_regex;
143 destr.data = location;
144 if(cxListAdd(cfg->destr, &destr)) {
145 return NULL;
146 }
137 } 147 }
138 148
139 ConfigNode *dir = obj->children_begin; 149 ConfigNode *dir = obj->children_begin;
140 while(dir) { 150 while(dir) {
141 if(dir->type == CONFIG_NODE_OBJECT || dir->type == CONFIG_NODE_DIRECTIVE) { 151 if(dir->type == CONFIG_NODE_OBJECT || dir->type == CONFIG_NODE_DIRECTIVE) {

mercurial