免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1105 | 回复: 0
打印 上一主题 下一主题

[C] c语言中使用pcre库 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2014-08-19 16:13 |只看该作者 |倒序浏览
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;


这段代码被反复执行时,产生了内存泄露,请问为什么啊?
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP