Add routines to duplicate a buffer.
Use buffer_dup.
Merge remote-tracking branch 'ccl/pull/564/head'

* ccl/pull/564/head:
  Use buffer_dup.
  Add routines to duplicate a buffer.