代码拉取完成,页面将自动刷新
#include <stdio.h>
#include <stdlib.h>
#include <malloc.h>
//export MALLOC_TRACE=a.log
//./mtrace
//tangzh@fanvil:~/work-1-11/code/project/malloc_debug$ mtrace mtrace a.log
//
//Memory not freed:
//-----------------
// Address Size Caller
// 0x000000000163e4a0 0x3 at /home/tangzh/work-1-11/code/project/malloc_debug/mtrace.c:51
void getMemStatus()
{
struct mallinfo info = mallinfo();
printf("arena = %d\n", info.arena);
printf("ordblks = %d\n", info.ordblks);
printf("smblks = %d\n", info.smblks);
printf("hblks = %d\n", info.hblks);
printf("hblkhd = %d\n", info.hblkhd);
printf("usmblks = %d\n", info.usmblks);
printf("fsmblks = %d\n", info.fsmblks);
printf("uordblks = %d\n", info.uordblks);
printf("fordblks = %d\n", info.fordblks);
printf("keepcost = %d\n", info.keepcost);
}
int main()
{
#if 0
char atCommand[90]="+IREG:02E9EFAF2E,6,01\r\n";//"+TIME:05:56:21,+ 02:00 GMT\r\n";
char *ptr[4];
ptr[0] = strtok((char*)atCommand, ":,\n");
ptr[1] = strtok(NULL, ":,\n");
ptr[2] = strtok(NULL, ":,\n");
ptr[3] = strtok(NULL, ":,\n");
printf("Hello world,\n ptr[0]=%s ,ptr[1]=%s ,ptr[2]=%s, ptr[3]=%s\n",ptr[0],ptr[1],ptr[2],ptr[3]);
int h,m,s;
int diff_gmt_h,diff_gmt_m;
char diff;
sscanf("+TIME:05:56:21,+ 02:00 GMT","+TIME:%d:%d:%d,%c %d:%d GMT", &h,&m,&s,&diff,&diff_gmt_h,&diff_gmt_m);
printf("h=%d,m=%d,s=%d,diff=%c,diff_gmt_h=%d,diff_gmt_m=%d\n",h,m,s,diff,diff_gmt_h,diff_gmt_m);
scanf("%d %d",&h,&diff);
printf("s eeeeeeeeeeeeeeeeeeeeee %d, %u h=%d diff=%d \n",strlen("a"),pthread_self(),h,diff);
switch('a'){
case 'a':
printf("ssssssssss\n");
break;
}
#endif
mtrace();
char ** p=malloc(8);
p[0]=malloc(2);
p[1]=malloc(3);
free(p[0]);
//free(p[1]);
if(p[1])free(p);
getMemStatus();
return 0;
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。