void __near* p;
s0 = ~(size_t)0 ^ (~(size_t)0 >> 1);
+#ifdef __BORLANDC__
+ while (s0 && (p = malloc(s0)) == NULL)
+#endif
+#ifdef __WATCOMC__
while (s0 && (p = _nmalloc(s0)) == NULL)
+#endif
s0 >>= 1;
if (p)
+#ifdef __BORLANDC__
+ free(p);
+#endif
+#ifdef __WATCOMC__
_nfree(p);
+#endif
s1 = s0 >> 1;
while (s1)
{
+#ifdef __BORLANDC__
+ if ((p = malloc(s0 + s1)) != NULL)
+#endif
+#ifdef __WATCOMC__
if ((p = _nmalloc(s0 + s1)) != NULL)
+#endif
{
s0 += s1;
+#ifdef __BORLANDC__
+ free(p);
+#endif
+#ifdef __WATCOMC__
_nfree(p);
+#endif
}
s1 >>= 1;
}
+#ifdef __BORLANDC__
+ while (s0 && (p = malloc(s0)) == NULL)
+#endif
+#ifdef __WATCOMC__
while (s0 && (p = _nmalloc(s0)) == NULL)
+#endif
s0 ^= s0 & -s0;
*Size = s0;
if (largest < sizeof(void __near*))
{
if (p != NULL)
+#ifdef __BORLANDC__
+ free(p);
+#endif
+#ifdef __WATCOMC__
_nfree(p);
+#endif
break;
}
*(void __near* __near*)p = NULL;
while (pFirst != NULL)
{
void __near* p = *(void __near* __near*)pFirst;
+#ifdef __BORLANDC__
+ free(pFirst);
+#endif
+#ifdef __WATCOMC__
_nfree(pFirst);
+#endif
pFirst = p;
}
return total;
return total;
}
+#ifdef __WATCOMC__
void huge* LargestHugeFreeBlock(size_t* Size)
{
size_t s0, s1;
write(heaphandle,scratch,strlen(scratch));
}
heapstat(heap_status, &scratch);
-
+
//near
strcpy(scratch,"\n == near ==\n\n");
write(heaphandle,scratch,strlen(scratch));
break;
case _HEAPEMPTY:
strcpy((str),"OK - heap is empty\n");
-
+
break;
case _HEAPBADBEGIN:
strcpy((str),"ERROR - heap is damaged\n");
break;
case _HEAPEMPTY:
//printf("OK - heap is empty\n");
-
+
break;
case _HEAPBADBEGIN:
printf("ERROR - heap is damaged\n");
printf("ERROR - bad node in heap\n");
}
}
-
+#endif
/*
============================
=