![]() Chapter Contents |
![]() Previous |
![]() Next |
| hpcalloc |
| SYNOPSIS | |
| DESCRIPTION | |
| RETURN VALUE | |
| ERRORS | |
| DIAGNOSTICS | |
| IMPLEMENTATION | |
| EXAMPLE | |
| RELATED FUNCTIONS | |
| SEE ALSO |
| SYNOPSIS |
#include <multheap.h> void *hpcalloc(_heap_id heapid, size_t n, size_t size);
| DESCRIPTION |
hpcalloc allocates a block
of dynamic memory from the heap indicated by heapid
to contain n elements of the size specified
by size . The block is cleared to binary zeroes before return.
| RETURN VALUE |
hpcalloc returns the address
of the first character of the new block of memory. The allocated block is
suitably aligned for storage of any type of data.
| ERRORS |
User ABEND 1205 or 1206 may occur if memory management data areas are overlaid.
| DIAGNOSTICS |
If adequate memory is not available, the heapid is invalid, or if 0 bytes are requested, NULL is
returned.
| IMPLEMENTATION |
See calloc for a description
of normal memory allocation. hpcalloc in effect is the same as calling hppush(heapid), calloc(size),
hppop().
| EXAMPLE |
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <multheap.h>
double *identity(_heap_id heapid, int size) {
double *matrix;
int i;
matrix = hpcalloc(heapid, sizeof(double), size*size);
if (matrix == NULL) return(NULL);
for (i = 0; i < size; ++i)
matrix[size*i + i] = 1.0;
return matrix;
}
| RELATED FUNCTIONS |
calloc, pool, 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.