Package ghidra.util

Interface ByteBufferUtils


public interface ByteBufferUtils
Some utilities for manipulating a ByteBuffer
  • Method Details

    • resize

      static ByteBuffer resize(ByteBuffer buf, int capacity)
      Resize a write-mode buffer

      This preserves the buffer contents

      Parameters:
      buf - the buffer
      capacity - the new capacity, greater or equal to the buffer's limit
      Returns:
      the new buffer
    • upsize

      static ByteBuffer upsize(ByteBuffer buf)
      Resize a write-mode buffer to twice its current capacity

      This preserves the buffer contents

      Parameters:
      buf - the buffer
      Returns:
      the new buffer
    • maskedEquals

      static boolean maskedEquals(ByteBuffer mask, ByteBuffer a, ByteBuffer b)
      Checks for equality, with a mask applied

      This considers the entire contents of both buffers without regard for position or limit. Both buffers must have equal capacities to be considered equal. The mask, if given, must have capacity equal to that of the first buffer a or an exception is thrown.

      Parameters:
      mask - a buffer containing the mask, or null to match all bytes exactly
      a - the first buffer
      b - the second buffer
      Returns:
      true if matches, false otherwise
      Throws:
      IllegalArgumentException - if mask and a have unequal capacities