C$MEMCPY (Dynamic Memory Routine)

Copies bytes between any two memory locations.
Note: This ACUCOBOL-GT library routine is available in this COBOL version. Any compatibility issues in this COBOL system are in the Compatibility Issues section at the end of the topic.

Usage

CALL "C$MEMCPY" 
    USING, BY VALUE, DEST-PTR, SRC-PTR, NUM-BYTES

Parameters

DEST-PTR USAGE POINTER or USING BY REFERENCE Contains the address of the first byte of the destination.
SRC-PTR USAGE POINTER or USING BY REFERENCE Contains the address of the first byte of the source.
NUM-BYTES USAGE UNSIGNED-INT or an unsigned numeric literal Indicates the number of bytes to copy.

Description

This routine copies NUM-BYTES bytes of memory from the address contained in SRC-PTR to the address contained in DEST-PTR. This routine is functionally similar to the M$COPY (Dynamic Memory Routine) routine except that parameters are passed by value instead of by reference. This routine can be used in cases where M$PUT and M$GET are not adequate. Note that this routine is relatively dangerous to use. It does not perform any error checking and can easily cause memory access violations if you pass it incorrect data. In other words, this routine is a very low-level routine and should be used cautiously.

You do not need to pass POINTER data items for SRC-PTR and DEST-PTR. If you prefer, either or both can be replaced by a data item passed BY REFERENCE. If you do this, then the address of the data item is passed to C$MEMCPY. For example, you can copy 10 bytes to DEST-ITEM from the memory address contained in SRC-PTR with:

     CALL "C$MEMCPY" 
        USING BY REFERENCE DEST-ITEM, BY VALUE SRC-PTR, 10

Compatibility Issues

None.