]> 4ch.mooo.com Git - 16.git/blobdiff - src/lib/16_hc.c
16_ca needs huge amounts of work and I should remember what needs to be done soon...
[16.git] / src / lib / 16_hc.c
index f2963158f9fa4154055d171b64277d4092a8fec3..e80d7714a85d50f33f0afdce976e1f44aa33b79b 100755 (executable)
@@ -421,13 +421,14 @@ size_t HC_GetNearFreeSize(void)
 \r
 void HC_heapdump(global_game_variables_t *gvar)\r
 {\r
-       struct _heapinfo fh_info, nh_info, h_info;\r
+       struct _heapinfo fh_info, nh_info;//, h_info;\r
        int heap_status;\r
-       size_t h_free, nh_free, fh_free, h_total, nh_total, fh_total, h_used, nh_used, fh_used;\r
+       size_t nh_free, fh_free, nh_total, fh_total, nh_used, fh_used;//,       h_free, h_total, h_used;\r
        byte    scratch[1024],str[16];\r
 \r
        HC_OpenDebug(gvar);\r
 \r
+#if 0\r
        strcpy(scratch,"\n      == default ==\n\n");\r
        write(gvar->handle.heaphandle,scratch,strlen(scratch));\r
        h_info._pentry = NULL;\r
@@ -435,13 +436,16 @@ void HC_heapdump(global_game_variables_t *gvar)
        for(;;) {\r
                heap_status = _heapwalk( &h_info );\r
                if( heap_status != _HEAPOK ) break;\r
-               strcpy(scratch,"  "); strcat(scratch,(h_info._useflag == _USEDENTRY ? "USED" : "FREE")); strcat(scratch," block at "); ultoa((dword)h_info._pentry,str,16); strcat(scratch,str); strcat(scratch," of size "); ultoa(h_info._size,str,10); strcat(scratch,str); strcat(scratch,"\n");\r
+               strcpy(scratch,"  "); strcat(scratch,(h_info._useflag == _USEDENTRY ? "USED" : "FREE")); strcat(scratch," block at ");\r
+               sprintf(str, "%Fp", h_info._pentry); //ultoa((dword)h_info._pentry,str,16);\r
+                       strcat(scratch,str); strcat(scratch," of size "); ultoa(h_info._size,str,10); strcat(scratch,str); strcat(scratch,"\n");\r
                if((h_info._useflag == _USEDENTRY ? "USED" : "FREE")=="FREE") h_free += h_info._size;\r
                if((h_info._useflag == _USEDENTRY ? "USED" : "FREE")=="USED") h_used += h_info._size;\r
                h_total += h_info._size;\r
                write(gvar->handle.heaphandle,scratch,strlen(scratch));\r
        }\r
        HC_heapstat(gvar, heap_status, &scratch);\r
+#endif\r
 \r
        //near\r
        strcpy(scratch,"\n      == near ==\n\n");\r
@@ -451,7 +455,9 @@ void HC_heapdump(global_game_variables_t *gvar)
        for(;;) {\r
                heap_status = _nheapwalk( &nh_info );\r
                if( heap_status != _HEAPOK ) break;\r
-               strcpy(scratch,"  "); strcat(scratch,(h_info._useflag == _USEDENTRY ? "USED" : "FREE")); strcat(scratch," block at "); ultoa((dword)nh_info._pentry,str,16); strcat(scratch,str); strcat(scratch," of size "); ultoa(nh_info._size,str,10); strcat(scratch,str); strcat(scratch,"\n");\r
+               strcpy(scratch,"  "); strcat(scratch,(nh_info._useflag == _USEDENTRY ? "USED" : "FREE")); strcat(scratch," block at ");\r
+               sprintf(str, "%Fp", nh_info._pentry); //ultoa((dword)nh_info._pentry,str,16);\r
+                       strcat(scratch,str); strcat(scratch," of size "); ultoa(nh_info._size,str,10); strcat(scratch,str); strcat(scratch,"\n");\r
 /*             printf( "  %s block at %Fp of size %4.4X\n",\r
 (nh_info._useflag == _USEDENTRY ? "USED" : "FREE"),\r
 nh_info._pentry, nh_info._size );*/\r
@@ -470,7 +476,9 @@ nh_info._pentry, nh_info._size );*/
        for(;;) {\r
                heap_status = _fheapwalk( &fh_info );\r
                if( heap_status != _HEAPOK ) break;\r
-               strcpy(scratch,"  "); strcat(scratch,(h_info._useflag == _USEDENTRY ? "USED" : "FREE")); strcat(scratch," block at "); ultoa((dword)fh_info._pentry,str,16); strcat(scratch,str); strcat(scratch," of size "); ultoa(fh_info._size,str,10); strcat(scratch,str); strcat(scratch,"\n");\r
+               strcpy(scratch,"  "); strcat(scratch,(fh_info._useflag == _USEDENTRY ? "USED" : "FREE")); strcat(scratch," block at ");\r
+               sprintf(str, "%Fp", fh_info._pentry); //ultoa((dword)fh_info._pentry,str,16);\r
+                       strcat(scratch,str); strcat(scratch," of size "); ultoa(fh_info._size,str,10); strcat(scratch,str); strcat(scratch,"\n");\r
                /*printf( "  %s block at %Fp of size %4.4X\n",\r
 (fh_info._useflag == _USEDENTRY ? "USED" : "FREE"),\r
 fh_info._pentry, fh_info._size );*/\r
@@ -484,7 +492,7 @@ fh_info._pentry, fh_info._size );*/
        strcpy(scratch,"\n");\r
        strcat(scratch,kittengets(2,0,"Memory Type         Total      Used       Free\n"));\r
        strcat(scratch,"----------------  --------   --------   --------\n");\r
-       printmeminfoline(&scratch, "Default", h_total, h_used, h_free);\r
+//     printmeminfoline(&scratch, "Default", h_total, h_used, h_free);\r
        printmeminfoline(&scratch, "Near", nh_total, nh_used, nh_free);\r
        printmeminfoline(&scratch, "Far", fh_total, fh_used, fh_free);\r
        strcat(scratch,"----------------  --------   --------   --------\n");\r
@@ -554,15 +562,22 @@ void HC_OpenDebug(global_game_variables_t *gvar)
 {\r
 #ifdef __BORLANDC__\r
        unlink("heap.16b");\r
-       gvar->handle.heaphandle = open("heap.16b", O_CREAT | O_WRONLY | O_TEXT);\r
+       gvar->handle.heaphandle = open(gvar->handle.heapdumpfilename, O_CREAT | O_WRONLY | O_TEXT);\r
 #endif\r
 #ifdef __WATCOMC__\r
        unlink("heap.16w");\r
-       gvar->handle.heaphandle = open("heap.16w", O_CREAT | O_WRONLY | O_TEXT);\r
+       gvar->handle.heaphandle = open(gvar->handle.heapdumpfilename, O_CREAT | O_WRONLY | O_TEXT);\r
 #endif\r
 }\r
 \r
 void HC_CloseDebug(global_game_variables_t *gvar)\r
 {\r
        close(gvar->handle.heaphandle);\r
+\r
+#ifdef __BORLANDC__\r
+       strcpy(gvar->handle.heapdumpfilename, "heap.16b");\r
+#endif\r
+#ifdef __WATCOMC__\r
+       strcpy(gvar->handle.heapdumpfilename, "heap.16w");\r
+#endif\r
 }\r