Re-add an indirection in bytevectors.
authorLudovic Courtès <ludo@gnu.org>
Sun, 15 Nov 2009 18:34:38 +0000 (19:34 +0100)
committerLudovic Courtès <ludo@gnu.org>
Mon, 16 Nov 2009 08:23:45 +0000 (09:23 +0100)
commit3fe87cf7aff396d7bd993aa009f48eb8afd6c1cd
treea27750be21b5bc418e564b4a665a804bf46c3729
parentc4daa519107798d06ae96d2f69dc211fc57cc8a3
Re-add an indirection in bytevectors.

The intent is to allow for mmap(3) bindings and to actually reuse
user-provided buffers in `scm_c_take_bytevector ()'.

* libguile/bytevectors.h (SCM_BYTEVECTOR_HEADER_SIZE): Increment.
  (SCM_BYTEVECTOR_CONTENTS): Take the pointer from the second word.
  (SCM_BYTEVECTOR_CONTIGUOUS_P): New macro.
  (SCM_BYTEVECTOR_ELEMENT_TYPE): Adjust to live alongside the CONTIGUOUS
  flag.

* libguile/bytevectors.c (SCM_BYTEVECTOR_SET_CONTENTS,
  SCM_BYTEVECTOR_SET_CONTIGUOUS_P): New macros.
  (SCM_BYTEVECTOR_SET_ELEMENT_TYPE): Adjust.
  (SCM_BYTEVECTOR_TYPED_LENGTH): Properly parenthesize.
  (make_bytevector): Adjust to new bytevector header.
  (make_bytevector_from_buffer): Reuse CONTENTS.
  (scm_c_shrink_bytevector): Differentiate between contiguous and
  non-contiguous bytevectors.
libguile/bytevectors.c
libguile/bytevectors.h