# FREEMAIN

## Syntax:

    FREEMAIN([addr][,lv][,sp])

## Arguments:

addr
  the address of the virtual storage to be freed. The format of this argument is the REXX printable hexadecimal format (e.g. '1FC0'), not the printable decimal format. Note that this format is the same as what is produced by the GETMAIN function when allocating storage.

  The addr argument must be supplied, except when freeing storage by subpool (i.e., you want to free the whole subpool with one FREEMAIN).

lv
  the length of the storage to be freed. This number is given in the REXX printable decimal format.

  The lv argument must be supplied except when freeing storage by subpool.

sp
  the subpool of the storage to be freed. This number is given in the REXX printable decimal format. The number must be between 0 and 127.

  The sp argument is not required, unless:

  - You are freeing by subpool only.
  - You used a subpool when you GETMAINed the storage. In this case you must specify the same subpool that you specified on the GETMAIN function.

  Note: You may not use the subpool-only FREEMAIN for subpool zero.

## Module Name:

SWXFREMN

## Service Description:

The FREEMAIN function is used to free storage that was previously acquired via the GETMAIN function. There are two formats you may use with FREEMAIN: You may either free storage by address and length (and optionally subpool); or you may free an entire subpool with one FREEMAIN.

## Returned Information:

The FREEMAIN function returns the FREEMAIN macro return code. If you CALL the FREEMAIN function, the returned value is contained in the RESULT special variable. In addition, the REXX special variable, RC, is also set to contain the FREEMAIN macro return code.

The following FREEMAIN return code values are possible:

0
  The virtual storage was freed.
4
  The virtual storage was not freed.

## Examples:

1. Call the FREEMAIN function to free the 1000 bytes virtual storage that is pointed to by the address in STGADDR:

       call freemain stgaddr, 1000

2. Call the FREEMAIN function to free all of subpool 3:

       call freemain , , 3

© Copyright 1998 by Open Software Technologies, Inc.