gtpc2m4bC/C++ Language Support User's Guide

gsysc-Get Storage from the System Heap

This function allocates storage from the system heap.

Format

#include <sysapi.h>
void *gsysc(int frames, char *token);

frames
This argument specifies the number of 4-KB frames to be allocated from the system heap.

token
This argument specifies an 8-byte string that identifies the storage being allocated. You need to specify this string when releasing storage to verify that the correct storage is released.

Normal Return

The system virtual memory (SVM) address of the storage requested is returned.

Error Return

If the request cannot be satisfied because the maximum size of the heap has been reached or there is not enough contiguous space available, 0 is returned.

If the system does not have enough real frames to satisfy the request, a catastrophic dump is taken and the system is IPLed again.

Programming Considerations

Examples

The following example allocates and releases 12 KB of system heap storage.

#include <sysapi.h>
#include <stdio.h>

·
·
·
{ /******************************************************************/ /* Allocate 12 KB of storage for a table used by many different */ /* ECBs. */ /******************************************************************/ int frames, rc; char * token = "TABLE40 "; struct table { char *name; int code; } *tbl_ptr; frames = 3; tbl_ptr = gsysc(frames, token); if (tbl_ptr == 0) { serrc_op(SERRC_EXIT, 0x1111, "Error allocating table.", NULL); }
·
·
·
rc = rsysc((void *)tbl_ptr, frames, token); if (rc == RSYSC_ERROR) { serrc_op(SERRC_EXIT, 0x2222, "Error releasing storage.", NULL); } }

Related Information

rsysc-Release Storage from the System Heap.