Memory files and hiperspace memory files
type=memory on the fopen() or freopen() call
that creates the file. A memory file, once created, exists until either
of the following happens:
- You explicitly remove it with
remove()orclrmemf() - The root program is terminated
While a memory file exists, you can just use another fopen() or freopen() that
specifies the memory file's name. As sample program CCNGOF1 shows
in Figure 1, you do not have to specify type=memory.
/* this example shows how fopen() may be used with memory files */
#include <stdio.h>
char text[3], *result;
FILE * fp;
int main(void)
{
fp = fopen("a.b", "w, type=memory"); /* Opens a memory file */
fprintf(fp, "%d\n",10); /* Writes to the file */
fclose(fp); /* Closes the file */
fp = fopen("a.b", "r"); /* Reopens the same */
/* file (already */
/* a memory file) */
if ((result=fgets(text,3,fp)) !=NULL) /* Retrieves results */
printf("value retrieved is %s\n",result);
fclose(fp); /* Closes the file */
return(0);
}A valid memory file name will match current file restrictions on a real file. Thus, a memory file name that is classified as UNIX file system can have more characters than can one classified as an MVS™ file name.
fp = fopen("a.b", "w, type=memory(hiperspace)");If you specify hiperspace and you are running in a CICS environment, z/OS XL C/C++ opens a regular memory file. If you are running
with the runtime options POSIX(ON) and TRAP(OFF),
specifying hiperspace has no effect; z/OS XL C/C++ will open a
regular memory file. You must specify TRAP(ON) to be able to create Hiperspace files.
Restriction: Hiperspace is not supported in AMODE 64 applications. If you specify hiperspace in AMODE 64 applications, z/OS XL C/C++ opens
a regular memory file.