<为爱走天涯>

导航

2013年4月22日 #

mtrace跟踪内存泄漏

摘要: mtrace是用来跟踪内存泄漏的功能开关,muntrace是用来关闭地它的跟功能。在使用mtrace时要在环境变量中添加宏MALLOC_TRACE,宏的值为生成的内存跟踪文件名。#include <stdio.h>#include <stdlib.h>#include <mcheck.h>int main(){ mtrace(); char *ptr = NULL; for(int i =0;i<2;i++) { int * p = (int*) malloc(sizeof(int)); p[1] = 1; } munt... 阅读全文

posted @ 2013-04-22 22:41 <为爱走天涯> 阅读(170) 评论(0) 推荐(0)

C 语言正则表达式与mmap结合使用

摘要: #include <stdio.h>#include <unistd.h>#include <fcntl.h>#include <sys/mman.h>#include <string.h>#include <errno.h>#include <regex.h>char *mptr = MAP_FAILED;int main(){ int status = 0; //FILE *fp = NULL; int cflags = REG_EXTENDED; regmatch_t pmatch[4]; const s 阅读全文

posted @ 2013-04-22 22:14 <为爱走天涯> 阅读(266) 评论(0) 推荐(0)