anchor.diff:         true -> Pad
       end.
   
  +%% @doc Copy all data for a reference.
  +%%
  +%% Recursively follows all pointers and copies them as well. So
  +%% copying a root object will effectively defragment a fragmented
  +%% message.
  +-spec copy(#ref{}) -> binary().
   copy(Ref) ->
       iolist_to_binary(
         flatten_ref_copy(copy_ref(Ref))).
   
  -null_ref(#ref{ data=Data }) -> #ref{ data=Data }.
  +%% @doc Get a null pointer.
  +%%
  +%% The up-side with this function in contrast to using a default
  +%% `#ref{}' record on its own is that the null reference returned by
  +%% this function knows about the schema and segment data of the
  +%% message for which it was based.
  +-spec null_ref(#ref{}) -> #ref{}.
  +null_ref(#ref{ data=Data }) -> #ref{ pos=-1, data=Data }.
   
   
   %% ===================================================================
  
positive.code:                                      count=Count
                                      } })).
  
  alloc_data(#ref{ segment=SegmentId, data=Data }=Ref0) ->
      Size = ref_data_size(Ref0),
      {Seg, Pos} = ecapnp_data:alloc(SegmentId, Size, Data),
      Seg = SegmentId, %% TODO: support far ptrs
      Ref = update_offset(Pos, Ref0),
      ok = write(Ref),
      Ref.
  
  alloc_list(Idx, #list_ref{ size=#struct_ref{ dsize=DSize, psize=PSize }=Tag,
                             count=Count }=Kind,
             Ref) ->
  
negative.code:         = get_segment(1 + ((Align + Len - 1) div 64), Ptr),
      set_segment(<<Pre/bits, Value:Len/bits, Post/bits>>, Ptr).
  
  %% @doc Resolve a far pointer.
  %%
  %% Usually this is done automatically when reading ref's.
  -spec follow_far(#ref{}) -> #ref{}.
  follow_far(#ref{ offset=Offset, data=Data,
                   kind=#far_ref{ segment=SegmentId, double_far=Double } }) ->
      Pad = get(SegmentId, Offset, Data, false),
  