From: <mi...@ca...> - 2003-06-12 19:24:20
|
Hello! I want to list all memory buffers that are either allocated or free by using the functions in malloc.h. However, this doesnt give me anything: void heapdump() { _HEAPINFO hinfo; int heapstatus; hinfo._pentry = NULL; while( ( heapstatus = _heapwalk( &hinfo ) ) == 0 ) { printf( "%6s block at %Fp of size %4.4X\n", ( hinfo._useflag == _USEDENTRY ? "USED" : "FREE" ), hinfo._pentry, hinfo._size ); } printf("heap status: %d\n",heapstatus); /* switch( heapstatus ) { case _HEAPEMPTY: printf( "OK - empty heap\n" ); break; case _HEAPEND: printf( "OK - end of heap\n" ); break; case _HEAPBADPTR: printf( "ERROR - bad pointer to heap\n" ); break; case _HEAPBADBEGIN: printf( "ERROR - bad start of heap\n" ); break; case _HEAPBADNODE: printf( "ERROR - bad node in heap\n" ); break; } */ } I was commenting out some stuff because malloc.h didnt define those macros. (why not?). However, the big problem is that _heapwalk returns -2 constantly. I got this code from: http://groups.google.com/groups?q=heapstatus+_heapwalk&hl=en&lr=&ie=UTF-8&selm=32B7552B.11FD%40deltanet.com&rnum=3 And changed _HEAPOK to 0, because _HEAPOK isnt defined in the mingw headers. Someone, help me! :) /Anders Lindén |