.subroutine concat_dynmem, stack
a_hdl1 ,n ;mem handle 1
a_hdl2 ,n ;mem handle 2
;max size of data to move
.define MAX64K ,65535
.align
record
datasize ,i4
datapos ,i4
frompos ,i4
structure dyndata
dynchar ,a1
.proc
;get this size of the two data areas
datapos = %mem_proc(DM_GETSIZE, a_hdl1)
datasize = %mem_proc(DM_GETSIZE, a_hdl2)
;resize first memory segment to hold result
a_hdl1 = %mem_proc(DM_RESIZ, datapos + datasize, a_hdl1)
frompos = 1
repeat
begin
if (datasize .le. MAX64K) ;less than 64k left
exitloop
;move memory in 64K chunks
^m(dyndata[1].dynchar(datapos+1:max64k), a_hdl1) =
& ^m(dyndata[1].dynchar(frompos:max64k), a_hdl2)
datasize = datasize - MAX64K
datapos = datapos + MAX64K
frompos = frompos + MAX64K
end
;move the remaining memory
if (datasize)
^m(dyndata[1].dynchar(datapos+1:datasize), a_hdl1) =
& ^m(dyndata[1].dynchar(frompos:datasize), a_hdl2)
xreturn
.end
|