home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
High Voltage Shareware
/
high1.zip
/
high1
/
DIR9
/
HEAP20.ZIP
/
HTEST.C
< prev
Wrap
C/C++ Source or Header
|
1993-10-05
|
2KB
|
81 lines
#include <alloc.h>
#include <conio.h>
#include <stdio.h>
#include "heap.h"
void main(void)
{
char far *ptr1,
far *ptr2,
far *ptr3;
unsigned int handle1,
handle2,
handle3;
clrscr();
printf("Without the Heap Library.\n\n");
printf("Free memory = %ld\n", farcoreleft());
printf("Allocating 10000 bytes.\n");
ptr1 = farmalloc(10000);
printf("Allocating 50000 bytes.\n");
ptr2 = farmalloc(50000);
printf("Allocating 20000 bytes.\n");
ptr3 = farmalloc(20000);
printf("Free memory = %ld\n\n", farcoreleft());
printf("Releasing second allocation.\n");
farfree(ptr2);
printf("Free memory = %ld\n\n", farcoreleft());
printf("Releasing first allocation.\n");
farfree(ptr1);
printf("Free memory = %ld\n\n", farcoreleft());
printf("Releasing third allocation.\n");
farfree(ptr3);
printf("Free memory = %ld\n\n", farcoreleft());
printf("Press a key..");
getch();
clrscr();
printf("With the Heap Library V%s\n\n", HeapVersion);
if (!InitHeap(3, 90000)) {
printf("Error initializing heap: #%d\n", HeapError);
printf("Not enough memory for this demonstration.\n");
return;
}
printf("Free memory = %ld\n", HeapUnused);
printf("Allocating 10000 bytes.\n");
handle1 = Halloc(10000);
printf("Allocating 50000 bytes.\n");
handle2 = Halloc(50000);
printf("Allocating 20000 bytes.\n");
handle3 = Halloc(20000);
printf("Free memory = %ld\n\n", HeapUnused);
printf("Releasing second allocation.\n");
Hfree(handle2);
printf("Free memory = %ld\n\n", HeapUnused);
printf("Releasing first allocation.\n");
Hfree(handle1);
printf("Free memory = %ld\n\n", HeapUnused);
printf("Releasing third allocation.\n");
Hfree(handle3);
printf("Free memory = %ld\n\n", HeapUnused);
UnInitHeap();
}