Skip to content
Snippets Groups Projects
  • Stefan Hajnoczi's avatar
    9dd6f7c2
    util/iov: add iov_discard_undo() · 9dd6f7c2
    Stefan Hajnoczi authored
    
    The iov_discard_front/back() operations are useful for parsing iovecs
    but they modify the array elements. If the original array is needed
    after parsing finishes there is currently no way to restore it.
    
    Although g_memdup() can be used before performing destructive
    iov_discard_front/back() operations, this is inefficient.
    
    Introduce iov_discard_undo() to restore the array to the state prior to
    an iov_discard_front/back() operation.
    
    Signed-off-by: default avatarStefan Hajnoczi <stefanha@redhat.com>
    Reviewed-by: default avatarLi Qiang <liq3ea@gmail.com>
    Message-Id: <20200917094455.822379-2-stefanha@redhat.com>
    9dd6f7c2
    History
    util/iov: add iov_discard_undo()
    Stefan Hajnoczi authored
    
    The iov_discard_front/back() operations are useful for parsing iovecs
    but they modify the array elements. If the original array is needed
    after parsing finishes there is currently no way to restore it.
    
    Although g_memdup() can be used before performing destructive
    iov_discard_front/back() operations, this is inefficient.
    
    Introduce iov_discard_undo() to restore the array to the state prior to
    an iov_discard_front/back() operation.
    
    Signed-off-by: default avatarStefan Hajnoczi <stefanha@redhat.com>
    Reviewed-by: default avatarLi Qiang <liq3ea@gmail.com>
    Message-Id: <20200917094455.822379-2-stefanha@redhat.com>