Skip to main content

Question on the ALLOCATE Statement

  • January 25, 2023
  • 2 replies
  • 0 views

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

2 replies

Chris Glazier
Forum|alt.badge.img+2

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


  • January 25, 2023

something like:

allocate mymem
     returning my-pointer

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

It's that simple eh.  Thanks