clrmemf() — Clear memory files

Standards

Standards / Extensions C or C++ Dependencies
Language Environment both  

Format

#include <stdio.h>

int clrmemf(int level);

General description

Removes memory files created by the current program and any program that was called using a non-POSIX system() call. clrmemf() can remove memory files regardless of whether they are open or not.

To avoid infringing on the user's name space, this nonstandard function has two names. One name is prefixed with two underscore characters, and one name is not. The name without the prefix underscore characters is exposed only when you use LANGLVL(EXTENDED).

To use this function, you must either invoke the function using its external entry point name (that is, the name that begins with two underscore characters), or compile with LANGLVL(EXTENDED). When you use LANGLVL(EXTENDED) any relevant information in the header is also exposed.

The argument level indicates which memory files are to be removed. The level can be one of the following:
__LOWER
Removes memory files that were created in other programs and called from this program using system().
__CURRENT
Removes only the memory files created at the current level.
__CURRENT_LOWER
Removes all the memory files created by the current program and by all the programs called at the current level.

Special behavior for multiple shared PICI C environments: Only files created by the C environment from which the clrmemf() function is called will be cleared.

Returned value

If successful, clrmemf() returns 0.

If unsuccessful, clrmemf() returns nonzero.

Example

/*
   In this example, when Program2 calls clrmemf()(__CURRENT) only
   A3.FILE and A4.FILE will be removed.
 */
/*****  Program1  *****/
⋮
   fp1 = fopen ("A1.FILE", "w,type=memory(hiperspace)");
   fp2 = fopen ("A2.FILE", "w,type=memory(hiperspace)");
   system("Program2");
⋮
/*****  Program2  *****/
⋮
   fp3 = fopen("A3.FILE","w,type=memory");
   fp4 = fopen("A4.FILE","w,type=memory");
   system("Program3");
⋮
   clrmemf(__CURRENT);
⋮
/*****  Program3  *****/
⋮
   fp5 = fopen("A5.FILE","w,type=memory");
   fp6 = fopen("A6.FILE","w,type=memory");
⋮

Related information