Frees a previously allocated DOS memory block
Declaration:
int freemem(unsigned segx);
Remarks:
freemem frees a memory block allocated by a previous call to allocmem.
segx is the segment address of the block.
Return Value:
On success, both functions return 0
On error,
_dos_freemem returns the DOS error code and sets errno to ENOMEM (Bad memory pointer)
freemem returns -1 and sets errno to ENOMEM (Insufficient memory)
program
#include <dos.h> #include <alloc.h> #include <stdio.h> int main(void) { unsigned int size, segp; int stat; size = 64; /* (64 x 16) = 1024 bytes */ stat = allocmem(size, &segp); if (stat < 0) printf("Allocated memory at segment: %x\n", segp); else printf("Failed: maximum number of\ paragraphs available is %u\n", stat); freemem(segp); return 0; } |
0 comments:
Post a Comment