sysmalloc.c
src/sysmalloc.c · 1.7 KB
From the archive Lpmud-CD.03.31beta1.tar.gz
Download the archive « Back to the archive contents
/*
* This is a dummy file, that will force the standard malloc
* to be used.
*/
#include <malloc.h>
void
sysmalloc_init()
{
mallopt(M_MXFAST, 100);
mallopt(M_NLBLKS, 1000);
mallopt(M_GRAIN, 8);
}
#define dump_stat(str) strcat(mbuf, str)
#define dump_stat1(str,p) sprintf(smbuf,str,p); strcat(mbuf, smbuf)
#define dump_stat2(str,stat,stat2) sprintf(smbuf,str,stat,stat2); strcat(mbuf,smbuf)
char *
dump_malloc_data()
{
static char mbuf[1024];
char smbuf[100];
struct mallinfo mem;
mem = mallinfo();
#if defined(__osf__) || defined(_SEQUENT_)
sprintf(mbuf,"Type Count Space (bytes)\n");
dump_stat2("sbrk requests: %8d %10d (a)\n",
mem.ordblks, mem.arena);
dump_stat2("large blocks: %8d %10d (b)\n",
0, mem.uordblks);
dump_stat2("large free blocks: %8d %10d (c)\n\n",
0, mem.fordblks);
dump_stat2("small blocks: %8d %10d (e)\n",
mem.smblks, mem.usmblks);
dump_stat2("small free blocks: %8d %10d (f)\n",
0, mem.fsmblks);
#else
sprintf(mbuf,"Type Count Space (bytes)\n");
dump_stat2("sbrk requests: %8d %10d (a)\n",
mem.ordblks, mem.arena);
dump_stat2("large blocks: %8d %10d (b)\n",
mem.allocated, mem.uordblks);
dump_stat2("large free blocks: %8d %10d (c)\n\n",
mem.ordblks - mem.allocated, mem.fordblks);
dump_stat2("small blocks: %8d %10d (e)\n",
0, mem.usmblks);
dump_stat2("small free blocks: %8d %10d (f)\n",
0, mem.fsmblks);
#endif
return mbuf;
}