Borland C++ reference

farfree

raw OCR

Frees a block from far heap.

Defined in header <alloc.h>

Syntax

#include <alloc.h>
void farfree(void far * block);

Portability

DOSUNIXWindowsANSI CC++ only
■■

Remarks

farfree releases a block of memory previously allocated from the far heap.

A tiny model program cannot make use of farfree.

In the small and medium memory models, blocks allocated by farmalloc cannot be freed with normal free, and blocks allocated with malloc cannot be freed with farfree. In these models, the two heaps are completely distinct.

Return value

None.

See also

Example

#include <stdio.h>
#include <alloc.h>
#include <string.h>
#include <dos.h>

int main(void)
{
   char far *fptr, *str = "Hello";
   /* allocate memory for the far pointer */
   fptr = (char far *) farcalloc (10, sizeof(char));

   /* copy "Hello" into allocated memory */
   /* Note: movedata is used because you might be  in a small data model, in which
      case a normal string copy routine can't be used  since it assumes the
      pointer size is near. */
   movedata(FP_SEG(str), FP_OFF(str),
            FP_SEG(fptr), FP_OFF(fptr),
            strlen(str));
   /* display string  (note the F modifier) V
   printf("Far string is: %Fs\n", fptr) ;

   /* free the memory */
   farfree(fptr);
   return 0;

Differences from modern implementations

Nothing recorded yet.

Modern references

These are search links, not yet checked by hand.