debugger/wam_debugger/src/main/com/thesett/aima/logic/fol/wam/debugger/monitor/ByteCodeMonitor.java
private void copyAndResizeCodeBuffer(ByteBuffer codeBuffer, int start, int length)
    {
        // Check the internal code buffer is large enough or resize it, then copy in the new instructions.
        int max = start + length;

        if (this.codeBuffer.limit() <= max)
        {
            ByteBuffer newCodeBuffer = ByteBuffer.allocate(max * 2);
            newCodeBuffer.put(this.codeBuffer.array(), 0, this.codeBuffer.limit());

            log.fine("Re-sized code buffer to " + (max * 2));
        }

        codeBuffer.position(start);
        codeBuffer.get(this.codeBuffer.array(), start, length);
    }
private void copyAndResizeCodeBuffer(ByteBuffer codeBuffer, int start, int length)
    {
        // Check the internal code buffer is large enough or resize it, then copy in the new instructions.
        int max = start + length;

        if (this.codeBuffer.limit() <= max)
        {
            ByteBuffer newCodeBuffer = ByteBuffer.allocate(max * 2);
            newCodeBuffer.put(this.codeBuffer.array(), 0, this.codeBuffer.limit());

            log.fine("Re-sized code buffer to " + (max * 2));
        }

        codeBuffer.position(start);
        codeBuffer.get(this.codeBuffer.array(), start, length);
    }
Copies code from the specified code buffer, into the internal one, resizing the internal code buffer if necessary
to make enough room.

@param codeBuffer The code buffer to copy from.
@param start      The start offset within the buffer of the new code.
@param length     The length of the new code.