Freeing storage

The EDCXFREE routine is called to return storage to the operating system. Its entry point must be @@XFREE. It uses the following parameters:
R0
The length of storage to be freed, in bytes
R1
The address of the area to be freed
Upon return, the following value is set.
R15
A system-dependent return code, which must be zero on success and nonzero otherwise

This routine is not provided with a save area. In addition to the linkage registers, this routine may freely alter registers 2 and 4.

If you provide your own EDCXFREE routine, it will be used when C library functions explicitly free storage. Whenever the library functions invoke operating-system services, there may be implicit requests to free storage that cannot be tailored.

Figure 1 shows an example of a routine that is used to free storage.

Figure 1. Example of routine to free storage
* this is an example of a routine to free storage
EDCXFREE CSECT
EDCXFREE AMODE ANY
EDCXFREE RMODE ANY
@@XFREE  DS    0H
         ENTRY @@XFREE
         BALR  R2,0
         USING *,R2
*
         FREEMAIN RC,SP=0,LV=(0),A=(1)
         BR    R14               return
*
R2       EQU   2
R14      EQU   14
         END