Call Returning a Dynamically Allocated Data Area from a Subprogram

* Calling program:

 program-id. calling.
 working-storage section.
 01 call-size   pic x(4) comp-5 value 64. 
 linkage section.
 01 call-area   pic x.
 procedure division.
     call "sub2" using call-size                 
              returning address of call-area
     if address of call-area not = null
         display "Contents of new area: " call-area(1:call-size)
     end-if
     stop run.
end program calling.
* Called program:

 program-id. sub2.
 working-storage section.
 01 sub-pointer usage pointer.
 linkage section.
 01 link-size   pic x(4) comp-5.
 01 link-area   pic x.
 procedure division using link-size.
     call "CBL_ALLOC_MEM" using sub-pointer
                                by value link-size
                                         0 size is 4
     if return-code = 0
         set address of link-area to sub-pointer
         move "Hello!" to link-area(1:link-size)
     else         
         set sub-pointer to null
     end-if
     exit program returning sub-pointer.