]> 4ch.mooo.com Git - 16.git/blob - src/lib/16_hc.c
FIXED farcoreleft() is a VERY important part of the farheap of MM. it is much larger...
[16.git] / src / lib / 16_hc.c
1 /* Project 16 Source Code~\r
2  * Copyright (C) 2012-2017 sparky4 & pngwen & andrius4669 & joncampbell123 & yakui-lover\r
3  *\r
4  * This file is part of Project 16.\r
5  *\r
6  * Project 16 is free software; you can redistribute it and/or modify\r
7  * it under the terms of the GNU General Public License as published by\r
8  * the Free Software Foundation; either version 3 of the License, or\r
9  * (at your option) any later version.\r
10  *\r
11  * Project 16 is distributed in the hope that it will be useful,\r
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
14  * GNU General Public License for more details.\r
15  *\r
16  * You should have received a copy of the GNU General Public License\r
17  * along with this program.  If not, see <http://www.gnu.org/licenses/>, or\r
18  * write to the Free Software Foundation, Inc., 51 Franklin Street,\r
19  * Fifth Floor, Boston, MA 02110-1301 USA.\r
20  *\r
21  */\r
22 /*\r
23         heap test stuff\r
24 */\r
25 \r
26 #include "src/lib/16_hc.h"\r
27 #include <malloc.h>\r
28 \r
29 //from ftp://213.85.246.177/pub/FreeBSD/ports/archivers/arj/work/arj-3.10.22/environ.c\r
30 //#ifdef __WATCOMC__\r
31 long HC_Newfarcoreleft()\r
32 {\r
33         void huge *hp;          static long rc=736L;    long s_rc;\r
34 \r
35         s_rc=rc;        rc+=2L;\r
36         do\r
37                 hp=halloc(rc-=2L, 1024);\r
38         while(hp==NULL&&rc>0L);\r
39         if(hp!=NULL)\r
40                 hfree(hp);\r
41         if(rc<s_rc)\r
42                 return(rc*1024L);\r
43         do\r
44         {\r
45                 hp=halloc(rc+=16L, 1024);\r
46                 if(hp!=NULL)\r
47                         hfree(hp);\r
48         } while(hp!=NULL);\r
49         return((rc-16L)*1024L);\r
50 }\r
51 //#endif\r
52 \r
53 void\r
54 #ifdef __BORLANDC__\r
55  *\r
56 #endif\r
57 #ifdef __WATCOMC__\r
58  __near*\r
59 #endif\r
60 HC_LargestFreeBlock(size_t* Size)\r
61 {\r
62         size_t s0, s1;\r
63 #ifdef __BORLANDC__\r
64         void * p;\r
65 #endif\r
66 #ifdef __WATCOMC__\r
67         void __near* p;\r
68 #endif\r
69 \r
70         s0 = ~(size_t)0 ^ (~(size_t)0 >> 1);\r
71 #ifdef __BORLANDC__\r
72         while (s0 && (p = malloc(s0)) == NULL)\r
73 #endif\r
74 #ifdef __WATCOMC__\r
75         while (s0 && (p = _nmalloc(s0)) == NULL)\r
76 #endif\r
77                 s0 >>= 1;\r
78 \r
79         if (p)\r
80 #ifdef __BORLANDC__\r
81                 free(p);\r
82 #endif\r
83 #ifdef __WATCOMC__\r
84                 _nfree(p);\r
85 #endif\r
86 \r
87         s1 = s0 >> 1;\r
88         while (s1)\r
89         {\r
90 #ifdef __BORLANDC__\r
91                 if ((p = malloc(s0 + s1)) != NULL)\r
92 #endif\r
93 #ifdef __WATCOMC__\r
94                 if ((p = _nmalloc(s0 + s1)) != NULL)\r
95 #endif\r
96                 {\r
97                         s0 += s1;\r
98 #ifdef __BORLANDC__\r
99                         free(p);\r
100 #endif\r
101 #ifdef __WATCOMC__\r
102                         _nfree(p);\r
103 #endif\r
104                 }\r
105         s1 >>= 1;\r
106         }\r
107 #ifdef __BORLANDC__\r
108         while (s0 && (p = malloc(s0)) == NULL)\r
109 #endif\r
110 #ifdef __WATCOMC__\r
111         while (s0 && (p = _nmalloc(s0)) == NULL)\r
112 #endif\r
113                 s0 ^= s0 & -s0;\r
114 \r
115         *Size = s0;\r
116         return p;\r
117 }\r
118 \r
119 size_t HC_coreleft(void)\r
120 {\r
121         size_t total = 0;\r
122         void __near* pFirst = NULL;\r
123         void __near* pLast = NULL;\r
124         for(;;)\r
125         {\r
126                 size_t largest;\r
127                 void __near* p = (void __near *)HC_LargestFreeBlock(&largest);\r
128                 if (largest < sizeof(void __near*))\r
129                 {\r
130                         if (p != NULL)\r
131 #ifdef __BORLANDC__\r
132                         free(p);\r
133 #endif\r
134 #ifdef __WATCOMC__\r
135                         _nfree(p);\r
136 #endif\r
137                         break;\r
138                 }\r
139                 *(void __near* __near*)p = NULL;\r
140                 total += largest;\r
141                 if (pFirst == NULL)\r
142                         pFirst = p;\r
143 \r
144                 if (pLast != NULL)\r
145                         *(void __near* __near*)pLast = p;\r
146                 pLast = p;\r
147         }\r
148 \r
149         while (pFirst != NULL)\r
150         {\r
151                 void __near* p = *(void __near* __near*)pFirst;\r
152 #ifdef __BORLANDC__\r
153                 free(pFirst);\r
154 #endif\r
155 #ifdef __WATCOMC__\r
156                 _nfree(pFirst);\r
157 #endif\r
158                 pFirst = p;\r
159         }\r
160         return total;\r
161 }\r
162 \r
163 void far* HC_LargestFarFreeBlock(size_t* Size)\r
164 {\r
165         size_t s0, s1;\r
166         void far* p;\r
167 \r
168         s0 = ~(size_t)0 ^ (~(size_t)0 >> 1);\r
169         while (s0 && (p = _fmalloc(s0)) == NULL)\r
170                 s0 >>= 1;\r
171 \r
172         if (p)\r
173                 _ffree(p);\r
174 \r
175         s1 = s0 >> 1;\r
176         while (s1)\r
177         {\r
178                 if ((p = _fmalloc(s0 + s1)) != NULL)\r
179                 {\r
180                         s0 += s1;\r
181                         _ffree(p);\r
182                 }\r
183         s1 >>= 1;\r
184         }\r
185         while (s0 && (p = _fmalloc(s0)) == NULL)\r
186                 s0 ^= s0 & -s0;\r
187 \r
188         *Size = s0;\r
189         return p;\r
190 }\r
191 \r
192 size_t HC_farcoreleft(void)\r
193 {\r
194         size_t total = 0;\r
195         void far* pFirst = NULL;\r
196         void far* pLast = NULL;\r
197         for(;;)\r
198         {\r
199                 size_t largest;\r
200                 void far* p = HC_LargestFarFreeBlock(&largest);\r
201                 if (largest < sizeof(void far*))\r
202                 {\r
203                         if (p != NULL)\r
204                         _ffree(p);\r
205                         break;\r
206                 }\r
207                 *(void far* far*)p = NULL;\r
208                 total += largest;\r
209                 if (pFirst == NULL)\r
210                         pFirst = p;\r
211 \r
212                 if (pLast != NULL)\r
213                         *(void far* far*)pLast = p;\r
214                 pLast = p;\r
215         }\r
216 \r
217         while (pFirst != NULL)\r
218         {\r
219                 void far* p = *(void far* far*)pFirst;\r
220                 _ffree(pFirst);\r
221                 pFirst = p;\r
222         }\r
223         return total;\r
224 }\r
225 \r
226 #ifdef __WATCOMC__\r
227 /*void huge* LargestHugeFreeBlock(size_t* Size)\r
228 {\r
229         size_t s0, s1;\r
230         void huge* p;\r
231 \r
232         s0 = ~(size_t)0 ^ (~(size_t)0 >> 1);\r
233         while (s0 && (p = halloc((dword)s0, 1)) == NULL)\r
234                 s0 >>= 1;\r
235 \r
236         if (p)\r
237                 hfree(p);\r
238 \r
239         s1 = s0 >> 1;\r
240         while (s1)\r
241         {\r
242                 if ((p = halloc((dword)(s0 + s1), 1)) != NULL)\r
243                 {\r
244                         s0 += s1;\r
245                         hfree(p);\r
246                 }\r
247         s1 >>= 1;\r
248         }\r
249         while (s0 && (p = halloc((dword)s0, 1)) == NULL)\r
250                 s0 ^= s0 & -s0;\r
251 \r
252         *Size = s0;\r
253         return p;\r
254 }\r
255 \r
256 size_t _hugecoreleft(void)\r
257 {\r
258         size_t total = 0;\r
259         void huge* pFirst = NULL;\r
260         void huge* pLast = NULL;\r
261         for(;;)\r
262         {\r
263                 size_t largest;\r
264                 void huge* p = LargestHugeFreeBlock(&largest);\r
265                 if (largest < sizeof(void huge*))\r
266                 {\r
267                         if (p != NULL)\r
268                         hfree(p);\r
269                         break;\r
270                 }\r
271                 *(void huge* huge*)p = NULL;\r
272                 total += largest;\r
273                 if (pFirst == NULL)\r
274                         pFirst = p;\r
275 \r
276                 if (pLast != NULL)\r
277                         *(void huge* huge*)pLast = p;\r
278                 pLast = p;\r
279         }\r
280 \r
281         while (pFirst != NULL)\r
282         {\r
283                 void huge* p = *(void huge* huge*)pFirst;\r
284                 hfree(pFirst);\r
285                 pFirst = p;\r
286         }\r
287         return total;\r
288 }\r
289 \r
290 void __based(__self)* LargestBasedFreeBlock(size_t* Size)\r
291 {\r
292         __segment segu;\r
293         size_t s0, s1;\r
294         void __based(__self)* p;\r
295 \r
296         s0 = ~(size_t)0 ^ (~(size_t)0 >> 1);\r
297         while (s0 && (p = _bmalloc(segu, s0)) == NULL)\r
298                 s0 >>= 1;\r
299 \r
300         if (p)\r
301                 _ffree(p);\r
302 \r
303         s1 = s0 >> 1;\r
304         while (s1)\r
305         {\r
306                 if ((p = _bmalloc(segu, s0 + s1)) != NULL)\r
307                 {\r
308                         s0 += s1;\r
309                         _ffree(p);\r
310                 }\r
311         s1 >>= 1;\r
312         }\r
313         while (s0 && (p = _bmalloc(segu, s0)) == NULL)\r
314                 s0 ^= s0 & -s0;\r
315 \r
316         *Size = s0;\r
317         return p;\r
318 }\r
319 \r
320 size_t _basedcoreleft(void)\r
321 {\r
322         __segment segu;\r
323         size_t total = 0;\r
324         void __based(segu)* pFirst = NULL;\r
325         void __based(segu)* pLast = NULL;\r
326         // allocate based heap\r
327         segu = _bHC_heapseg( 1024 );\r
328         if( segu == _NULLSEG ) {\r
329                 printf( "Unable to allocate based heap\n" );\r
330                 return 0;\r
331 \r
332         }\r
333         else\r
334 \r
335         for(;;)\r
336         {\r
337                 size_t largest;\r
338                 void __based(segu)* p = LargestBasedFreeBlock(&largest);\r
339                 if (largest < sizeof(void far*))\r
340                 {\r
341                         if (p != NULL)\r
342                         _ffree(p);\r
343                         break;\r
344                 }\r
345                 *(void far* far*)p = NULL;\r
346                 total += largest;\r
347                 if (pFirst == NULL)\r
348                         pFirst = p;\r
349 \r
350                 if (pLast != NULL)\r
351                         *(void far* far*)pLast = p;\r
352                 pLast = p;\r
353         }\r
354 \r
355         while (pFirst != NULL)\r
356         {\r
357                 void far* p = *(void far* far*)pFirst;\r
358                 _ffree(pFirst);\r
359                 pFirst = p;\r
360         }\r
361         return total;\r
362 }*/\r
363 \r
364 size_t HC_GetFreeSize(void)\r
365 {\r
366         struct _heapinfo h_info;\r
367         int heap_status;\r
368         size_t h_free=0, h_total=0, h_used=0;\r
369 \r
370         h_info._pentry = NULL;\r
371         for(;;) {\r
372                 heap_status = _heapwalk( &h_info );\r
373                 if( heap_status != _HEAPOK ) break;\r
374                 if((h_info._useflag == _USEDENTRY ? "USED" : "FREE")=="FREE") h_free += h_info._size;\r
375                 if((h_info._useflag == _USEDENTRY ? "USED" : "FREE")=="USED") h_used += h_info._size;\r
376                 h_total += h_info._size;\r
377         }\r
378         HC_heapstat0(heap_status);\r
379         return h_free;\r
380 }\r
381 \r
382 size_t HC_GetFarFreeSize(void)\r
383 {\r
384         struct _heapinfo fh_info;\r
385         int heap_status;\r
386         size_t fh_free=0, fh_total=0, fh_used=0;\r
387 \r
388         fh_info._pentry = NULL;\r
389         for(;;) {\r
390                 heap_status = _fheapwalk( &fh_info );\r
391                 if( heap_status != _HEAPOK ) break;\r
392                 if((fh_info._useflag == _USEDENTRY ? "USED" : "FREE")=="FREE") fh_free += fh_info._size;\r
393                 if((fh_info._useflag == _USEDENTRY ? "USED" : "FREE")=="USED") fh_used += fh_info._size;\r
394                 fh_total += fh_info._size;\r
395         }\r
396         HC_heapstat0(heap_status);\r
397         return fh_free;\r
398 }\r
399 \r
400 size_t HC_GetNearFreeSize(void)\r
401 {\r
402         struct _heapinfo nh_info;\r
403         int heap_status;\r
404         size_t nh_free=0, nh_total=0, nh_used=0;\r
405 \r
406         nh_info._pentry = NULL;\r
407         for(;;) {\r
408                 heap_status = _nheapwalk( &nh_info );\r
409                 if( heap_status != _HEAPOK ) break;\r
410                 if((nh_info._useflag == _USEDENTRY ? "USED" : "FREE")=="FREE") nh_free += nh_info._size;\r
411                 if((nh_info._useflag == _USEDENTRY ? "USED" : "FREE")=="USED") nh_used += nh_info._size;\r
412                 nh_total += nh_info._size;\r
413         }\r
414         HC_heapstat0(heap_status);\r
415         return nh_free;\r
416 }\r
417 \r
418 void HC_heapdump(global_game_variables_t *gvar)\r
419 {\r
420         struct _heapinfo fh_info, nh_info;//, h_info;\r
421         int heap_status;\r
422         size_t nh_free, fh_free, nh_total, fh_total, nh_used, fh_used;//,       h_free, h_total, h_used;\r
423         byte    scratch[1024],str[16];\r
424 \r
425         HC_OpenDebug(gvar);\r
426 \r
427 #if 0\r
428         strcpy(scratch,"\n      == default ==\n\n");\r
429         write(gvar->handle.heaphandle,scratch,strlen(scratch));\r
430         h_info._pentry = NULL;\r
431         h_free=0; h_total=0; h_used=0;\r
432         for(;;) {\r
433                 heap_status = _heapwalk( &h_info );\r
434                 if( heap_status != _HEAPOK ) break;\r
435                 strcpy(scratch,"  "); strcat(scratch,(h_info._useflag == _USEDENTRY ? "USED" : "FREE")); strcat(scratch," block at ");\r
436                 sprintf(str, "%Fp", h_info._pentry); //ultoa((dword)h_info._pentry,str,16);\r
437                         strcat(scratch,str); strcat(scratch," of size "); ultoa(h_info._size,str,10); strcat(scratch,str); strcat(scratch,"\n");\r
438                 if((h_info._useflag == _USEDENTRY ? "USED" : "FREE")=="FREE") h_free += h_info._size;\r
439                 if((h_info._useflag == _USEDENTRY ? "USED" : "FREE")=="USED") h_used += h_info._size;\r
440                 h_total += h_info._size;\r
441                 write(gvar->handle.heaphandle,scratch,strlen(scratch));\r
442         }\r
443         HC_heapstat(gvar, heap_status, &scratch);\r
444 #endif\r
445 \r
446         //near\r
447         strcpy(scratch,"\n      == near ==\n\n");\r
448         write(gvar->handle.heaphandle,scratch,strlen(scratch));\r
449         nh_info._pentry = NULL;\r
450         nh_free=0; nh_total=0; nh_used=0;\r
451         for(;;) {\r
452                 heap_status = _nheapwalk( &nh_info );\r
453                 if( heap_status != _HEAPOK ) break;\r
454                 strcpy(scratch,"  "); strcat(scratch,(nh_info._useflag == _USEDENTRY ? "USED" : "FREE")); strcat(scratch," block at ");\r
455                 sprintf(str, "%Fp", nh_info._pentry); //ultoa((dword)nh_info._pentry,str,16);\r
456                         strcat(scratch,str); strcat(scratch," of size "); ultoa(nh_info._size,str,10); strcat(scratch,str); strcat(scratch,"\n");\r
457 /*              printf( "  %s block at %Fp of size %4.4X\n",\r
458 (nh_info._useflag == _USEDENTRY ? "USED" : "FREE"),\r
459 nh_info._pentry, nh_info._size );*/\r
460                 if((nh_info._useflag == _USEDENTRY ? "USED" : "FREE")=="FREE") nh_free += nh_info._size;\r
461                 if((nh_info._useflag == _USEDENTRY ? "USED" : "FREE")=="USED") nh_used += nh_info._size;\r
462                 nh_total += nh_info._size;\r
463                 write(gvar->handle.heaphandle,scratch,strlen(scratch));\r
464         }\r
465         HC_heapstat(gvar, heap_status, &scratch);\r
466 \r
467         //far\r
468         strcpy(scratch,"\n      == far ==\n\n");\r
469         write(gvar->handle.heaphandle,scratch,strlen(scratch));\r
470         fh_info._pentry = NULL;\r
471         fh_free=0; fh_total=0; fh_used=0;\r
472         for(;;) {\r
473                 heap_status = _fheapwalk( &fh_info );\r
474                 if( heap_status != _HEAPOK ) break;\r
475                 strcpy(scratch,"  "); strcat(scratch,(fh_info._useflag == _USEDENTRY ? "USED" : "FREE")); strcat(scratch," block at ");\r
476                 sprintf(str, "%Fp", fh_info._pentry); //ultoa((dword)fh_info._pentry,str,16);\r
477                         strcat(scratch,str); strcat(scratch," of size "); ultoa(fh_info._size,str,10); strcat(scratch,str); strcat(scratch,"\n");\r
478                 /*printf( "  %s block at %Fp of size %4.4X\n",\r
479 (fh_info._useflag == _USEDENTRY ? "USED" : "FREE"),\r
480 fh_info._pentry, fh_info._size );*/\r
481                 if((fh_info._useflag == _USEDENTRY ? "USED" : "FREE")=="FREE") fh_free += fh_info._size;\r
482                 if((fh_info._useflag == _USEDENTRY ? "USED" : "FREE")=="USED") fh_used += fh_info._size;\r
483                 fh_total += fh_info._size;\r
484                 write(gvar->handle.heaphandle,scratch,strlen(scratch));\r
485         }\r
486         HC_heapstat(gvar, heap_status, &scratch);\r
487 \r
488         strcpy(scratch,"\n");\r
489         strcat(scratch,kittengets(2,0,"Memory Type         Total      Used       Free\n"));\r
490         strcat(scratch,"----------------  --------   --------   --------\n");\r
491 //      printmeminfoline(&scratch, "Default", h_total, h_used, h_free);\r
492         printmeminfoline(&scratch, "Near", nh_total, nh_used, nh_free);\r
493         printmeminfoline(&scratch, "Far", fh_total, fh_used, fh_free);\r
494         strcat(scratch,"----------------  --------   --------   --------\n");\r
495         strcat(scratch,"HC_coreleft = ");                       ultoa((dword)HC_coreleft(),str,10);                     strcat(scratch,str);    strcat(scratch,"\n");\r
496         strcat(scratch,"HC_farcoreleft = ");                    ultoa((dword)HC_farcoreleft(),str,10);          strcat(scratch,str);    strcat(scratch,"\n");\r
497         strcat(scratch,"HC_Newfarcoreleft = ");                 ultoa((dword)HC_Newfarcoreleft(),str,10);               strcat(scratch,str);    strcat(scratch,"\n");\r
498         strcat(scratch,"HC_GetFreeSize = ");            ultoa((dword)HC_GetFreeSize(),str,10);          strcat(scratch,str);    strcat(scratch,"\n");\r
499         strcat(scratch,"HC_GetNearFreeSize = ");        ultoa((dword)HC_GetNearFreeSize(),str,10);      strcat(scratch,str);    strcat(scratch,"\n");\r
500         strcat(scratch,"HC_GetFarFreeSize = ");         ultoa((dword)HC_GetFarFreeSize(),str,10);       strcat(scratch,str);    strcat(scratch,"\n");\r
501         strcat(scratch,"coreleft = ");                          ultoa((dword)coreleft(),str,10);                                strcat(scratch,str);    strcat(scratch,"\n");\r
502         strcat(scratch,"farcoreleft = ");                       ultoa((dword)farcoreleft(),str,10);                     strcat(scratch,str);    strcat(scratch,"\n");\r
503         strcat(scratch,"stackavail = ");                        ultoa((dword)stackavail(),str,10);                      strcat(scratch,str);    strcat(scratch,"\n");\r
504         write(gvar->handle.heaphandle,scratch,strlen(scratch));\r
505         HC_CloseDebug(gvar);\r
506 }\r
507 \r
508 void HC_heapstat(global_game_variables_t *gvar, int heap_status, byte *str)\r
509 {\r
510         switch( heap_status ) {\r
511                 case _HEAPEND:\r
512                         strcpy((str),"OK - end of heap\n");\r
513                 break;\r
514                 case _HEAPEMPTY:\r
515                         strcpy((str),"OK - heap is empty\n");\r
516 \r
517                 break;\r
518                 case _HEAPBADBEGIN:\r
519                         strcpy((str),"ERROR - heap is damaged\n");\r
520                 break;\r
521                 case _HEAPBADPTR:\r
522                         strcpy((str),"ERROR - bad pointer to heap\n");\r
523                 break;\r
524                 case _HEAPBADNODE:\r
525                         strcpy((str),"ERROR - bad node in heap\n");\r
526         }\r
527         write(gvar->handle.heaphandle,(str),strlen((str)));\r
528 }\r
529 \r
530 void HC_heapstat0(int heap_status)\r
531 {\r
532         switch( heap_status ) {\r
533                 case _HEAPEND:\r
534                         //printf("OK - end of heap\n");\r
535                 break;\r
536                 case _HEAPEMPTY:\r
537                         //printf("OK - heap is empty\n");\r
538                 break;\r
539                 case _HEAPBADBEGIN:\r
540                         printf("ERROR - heap is damaged\n");\r
541                 break;\r
542                 case _HEAPBADPTR:\r
543                         printf("ERROR - bad pointer to heap\n");\r
544                 break;\r
545                 case _HEAPBADNODE:\r
546                         printf("ERROR - bad node in heap\n");\r
547         }\r
548 }\r
549 #endif\r
550 /*\r
551 ============================\r
552 =\r
553 = HC_OpenDebug / HC_CloseDebug\r
554 =\r
555 = Opens a binary file with the handle "heaphandle"\r
556 =\r
557 ============================\r
558 */\r
559 void HC_OpenDebug(global_game_variables_t *gvar)\r
560 {\r
561 #ifdef __BORLANDC__\r
562         unlink("heap.16b");\r
563         gvar->handle.heaphandle = open(gvar->handle.heapdumpfilename, O_CREAT | O_WRONLY | O_TEXT);\r
564 #endif\r
565 #ifdef __WATCOMC__\r
566         unlink("heap.16w");\r
567         gvar->handle.heaphandle = open(gvar->handle.heapdumpfilename, O_CREAT | O_WRONLY | O_TEXT);\r
568 #endif\r
569 }\r
570 \r
571 void HC_CloseDebug(global_game_variables_t *gvar)\r
572 {\r
573         close(gvar->handle.heaphandle);\r
574 \r
575 #ifdef __BORLANDC__\r
576         strcpy(gvar->handle.heapdumpfilename, "heap.16b");\r
577 #endif\r
578 #ifdef __WATCOMC__\r
579         strcpy(gvar->handle.heapdumpfilename, "heap.16w");\r
580 #endif\r
581 }\r
582 \r
583 #ifdef __WATCOMC__\r
584 unsigned long farcoreleft()\r
585 {\r
586         _fheapgrow();\r
587         //return HC_farcoreleft();\r
588 // #ifdef __BORLANDC__\r
589 //      r 0x90000UL-16UL\r
590 // #endif\r
591 \r
592         return 0x90000UL+16UL;\r
593 }\r
594 \r
595 unsigned long coreleft()\r
596 {\r
597         _nheapgrow();\r
598         return _memavl();\r
599 }\r
600 #endif\r