Skip to main content

The reference on the ALLOCATE statement (ALLOCATE Statement (COBOL) (microfocus.com)) says that:

If the specified amount of storage is not available for allocation:

    • If the RETURNING phrase is specified, the data item referenced by data-name-2 is set to the predefined address NULL.

My question is can someone give me an example of how to test the returned USAGE POINTER variable for NULL?

Thanks

The reference on the ALLOCATE statement (ALLOCATE Statement (COBOL) (microfocus.com)) says that:

If the specified amount of storage is not available for allocation:

    • If the RETURNING phrase is specified, the data item referenced by data-name-2 is set to the predefined address NULL.

My question is can someone give me an example of how to test the returned USAGE POINTER variable for NULL?

Thanks

something like:

allocate mymem
     returning my-pointer

if my-pointer = null
    display "memory alloc failed"
end-if


something like:

allocate mymem
     returning my-pointer

if my-pointer = null
    display "memory alloc failed"
end-if

It's that simple eh.  Thanks