Chapter Contents

Previous

Next
hpfree

hpfree



Free a Block of Memory from Heap


SYNOPSIS
DESCRIPTION
RETURN VALUE
ERRORS
IMPLEMENTATION
EXAMPLE
RELATED FUNCTIONS
SEE ALSO


SYNOPSIS

#include <multheap.h>
void hpfree(_heap_id heapid, void *block);


DESCRIPTION

hpfree frees a block of dynamic memory from a heap indicated by heapid.


RETURN VALUE

hpfree has no return value.


ERRORS

User ABEND 1206, 1207, or 1208 may occur if memory management data areas are overlaid. User ABEND 1208 will probably occur if the block pointer is invalid; that is, if it does not address a previously allocated area of memory that has not already been freed.


IMPLEMENTATION

In most cases if an entire page of memory is unused after a free call, the page is returned to the operating system (unless the pointer is in the heap's initial allocation). For memory above the bar, the memory is not returned until the heap is freed by a call to hpdestroy.


EXAMPLE

#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <multheap.h>
main()
{
char *source, *copy;

   source = "A simple line for the hpfree example ";
   /* Allocate space for a copy for source. */
   copy = hpalloc(_HEAP_STD, strlen(source) + 1);
   /* Copy if there is space. */
   if (copy)
   {
     strcpy(copy,source);
     puts(copy);
   }
     else puts("hpalloc failed to allocate memory for copy.");

   hpfree(_HEAP_STD, copy);
}


RELATED FUNCTIONS

hpalloc, hpcalloc, hppoolcreate


SEE ALSO

"Memory Allocation Functions" in Chapter 2, "Function Categories" of the SAS/C Library Reference, Volume 1.


Chapter Contents

Previous

Next

Top of Page

Copyright © 2004 by SAS Institute Inc., Cary, NC, USA. All rights reserved.