Pointer (Collection<Integer> indices) { if (indices == null || indices.isEmpty()) { return null; } final int step = Native.getNativeSize(Integer.class); final Pointer mem = new Pointer(Native.malloc((long)indices.size() * step)); int offset = 0; for (Integer i : indices) { mem.setInt(offset, i); offset += step; } return mem; }