mallpc free 错误定位
2013-08-09 15:39
134 查看
#include <stdio.h>
#include <stdlib.h>
void *
debug_malloc(size_t size, const char *file, int line, const char *func)
{
void *p;
p = malloc(size);
printf("%s:%d:%s:malloc(%ld): p=0x%lx\n",
file, line, func, size, (unsigned long)p);
return p;
}
#define malloc(s) debug_malloc(s, __FILE__, __LINE__, __func__)
#define free(p) do { \
printf("%s:%d:%s:free(0x%lx)\n", __FILE__, __LINE__, \
__func__, (unsigned long)p); \
free(p); \
} while (0)
int
main(int argc, char *argv[])
{
char *p;
p = malloc(1024);
free(p);
return 0;
}
#include <stdlib.h>
void *
debug_malloc(size_t size, const char *file, int line, const char *func)
{
void *p;
p = malloc(size);
printf("%s:%d:%s:malloc(%ld): p=0x%lx\n",
file, line, func, size, (unsigned long)p);
return p;
}
#define malloc(s) debug_malloc(s, __FILE__, __LINE__, __func__)
#define free(p) do { \
printf("%s:%d:%s:free(0x%lx)\n", __FILE__, __LINE__, \
__func__, (unsigned long)p); \
free(p); \
} while (0)
int
main(int argc, char *argv[])
{
char *p;
p = malloc(1024);
free(p);
return 0;
}
相关文章推荐
- 定位错误:glibc detected :double free or corruption (!prev): 0x08a03b88
- Lua的pcall错误处理定位行号
- perl 分析binlog 定位错误sql 思路
- 如何快速定位tomcat集群中的错误日志出处
- Opengl中提示错误“无法启动此程序,因为计算机中丢失freeglut.dll。尝试重新安装该程序以解决此问题。”
- 快速定位错误代码!友盟错误分析放大招
- xCode里面设置NSZombieEnabled定位错误
- 关于oop错误定位的学习
- spring+mybatis启动NoClassDefFoundError异常分析三部曲之二:定位错误
- 总线错误和段错误问题的定位
- 如何定位Android NDK开发中遇到的错误
- 依据linux Oops信息准确定位错误代码所在行
- 实战:结合Dr.Watson系统日志和Vc6来定位多线程环境下程序异常退出的错误
- 如何定位Android NDK开发中遇到的错误
- source insight 集成IAR编译构建功能及代码错误警告定位
- EXC_BAD_ACCESS的错误定位
- Best Free Apps to Stream Videos from PC to Android Phone
- 错误:“无法定位程序输入点xxx.dll于动态链接库上”
- 百度定位SDK错误:Couldn’t load locSDK3: findLibrary returned null
- 设置Global Breakpoint定位错误代码所在位置