Chapter Contents

Previous

Next
hpcreate

hpcreate



Create New Heap


SYNOPSIS
DESCRIPTION
RETURN VALUE
DIAGNOSTICS
IMPLEMENTATION
EXAMPLE
RELATED FUNCTIONS
SEE ALSO


SYNOPSIS

#include <multheap.h>
_heap_id hpcreate(_heap_attr _ _near *ha,
               char _ _near *name);


DESCRIPTION

hpcreate creates a new heap based on attributes from the structure pointed to by ha. name can either be NULL or point to a unique null-terminated string (truncated to 16 bytes) that will name the heap for diagnostic purposes.


RETURN VALUE

hpcreate returns the ID of the newly created heap. This ID is used to specify the heap to be used by other multi-heap functions.


DIAGNOSTICS

If the heap attribute structure pointed to by ha is invalid, NULL is returned. Possible reasons for rejecting a heap attribute structure include the following: the version number was invalid (possibly indicating an uninitialized structure), a subpool other than 131 was specified for a shared heap, or the name was associated with another heap. NULL may also be returned if hpcreate was unable to allocate memory for control information.


IMPLEMENTATION

Only control information is allocated during hpcreate. Heap storage will not be allocated from the heap until hpalloc, hpcalloc, or another multiheap storage function is invoked.


EXAMPLE

#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <multheap.h>
_heap_attr attr;
main()
{
   _heap_id id1;
   
// create a user heap - shared and above
//  the bar

   hpattr(&attr);
   attr.flags = HPATTR_SHARED;     
   attr.amode = HPLOC_64;          
   attr.subpool = HPSUBPOOL_DEFAULT;              
   attr.initial = 1000000000;            
   attr.overflow = 0;            
   id1 = hpcreate(&attr, "Above The Bar1");  
   if (!id1)                       
   {                               
      WTP("error in hpcreate.\n"); 
      return -1;                   
   }                               
   WTP("id1 = %04hX\n", id1);
                         
}


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.