- 论坛徽章:
- 0
|
302 pcre *re;
303 const char *error;
304 int erroffset;
305 int rc;
306 char pattern[KRK_MAX_HTTP_EXPECTED+1] = {0,};
307
308 memcpy(pattern, hcp->expected, hcp->expected_len);
309
310 re = pcre_compile(pattern, PCRE_CASELESS, &error, &erroffset, NULL);
311 if (re == NULL) {
312 fprintf(stderr,"compile pcre failed\n");
313 return KRK_ERROR;
314 }
315 /*match headers and line*/
316 rc = pcre_exec(re, NULL, hrh->header_start,
317 hrh->header_last - hrh->header_start, 0, 0, NULL, 0);
318 if (rc < 0) {
319 /*match body*/
320 rc = pcre_exec(re, NULL, hrh->body_start, hrh->body_len, 0, 0, NULL, 0);
321 if (rc < 0) {
322 pcre_free(re);
323 return KRK_ERROR;
324 }
325 }
326
327
328 pcre_free(re);
329 return KRK_OK;
这段代码被反复执行时,产生了内存泄露,请问为什么啊? |
|