code: def memory_allocation(library, session, size, extended=False):
      
      offset = ViBusAddress()
      if extended:
          ret = library.viMemAllocEx(session, size, byref(offset))
      else:
          ret = library.viMemAlloc(session, size, byref(offset))
      return offset, ret
docs: Allocates memory from a resource's memory region.
  
      Corresponds to viMemAlloc* functions of the VISA library.
  
      :param library: the visa library wrapped by ctypes.
      :param session: Unique logical identifier to a session.
      :param size: Specifies the size of the allocation.
      :param extended: Use 64 bits offset independent of the platform.
      :return: offset of the allocated memory, return value of the library call.
      :rtype: offset, :class:`pyvisa.constants.StatusCode`