Check if mem1 and mem2 occupy contiguous memory and return the offset of mem1 in the parent buffer in offset.