Class AbstractNativeMemory

    • Constructor Detail

      • AbstractNativeMemory

        protected AbstractNativeMemory​(NativeAddressHolder addressHolder)
        Create a static memory slice which will NOT be freed - its static.
        Parameters:
        addressHolder - the base address.
      • AbstractNativeMemory

        public AbstractNativeMemory​(AbstractNativeMemory parent,
                                    long offset,
                                    long sizeInBytes)
        Creates a new memory which will be freed at the end of life.
        Parameters:
        sizeInBytes -
    • Method Detail

      • getSizeInBytes

        public static final long getSizeInBytes​(AbstractNativeMemory instance)
        Get the size in bytes if instance. Wrap instance.getSizeInBytes() - so the namespace of instanes of AbstractNativeMemory is not pollutet.
        Parameters:
        instance - the instance.
        Returns:
        the instance.getSizeInBytes() .
      • offsetof

        public static long offsetof​(AbstractNativeMemory member)
        Get the offset of member to direct parent.
        Parameters:
        member - the direct member of parent.
        Returns:
        the offset om menber in its parent.
      • calcOffsetForAlignment

        public static long calcOffsetForAlignment​(AbstractNativeMemory mem,
                                                  Alignment structAlignment,
                                                  long startOffset)
        Neede for calculating baseaddress of onTheFly
         
          int8_t data0;
          struct onTheFly {
           int64_t first
          };
         
        Parameters:
        mem - the mem to put datat0 and onTheFly
        structAlignment - the alignment of onTheFly here ist will be 8 byte from int64_t
        startOffset - the offset in mem where you intend to place onTheFly
        Returns:
        the aligned offset
      • isSameAddress

        public static boolean isSameAddress​(NativeAddressHolder nativeAddress,
                                            AbstractNativeMemory om)
        test if adresses are the same. If either nativeAddress or om is null and the other has a address of 0 it is considered as the same address.
        Parameters:
        nativeAddress -
        om -
        Returns:
      • getOffset

        protected final long getOffset()
        calc the offset
        Returns:
      • getSizeInBytes

        protected abstract long getSizeInBytes()