f_dump_buffer ============= Character storage and a cursor, the Fortran derived type behind the C ``f90_f_dump_buffer_*`` handles and the C++ ``Futile::FDumpBuffer`` class. .. code-block:: fortran use futile ! or: use f_utils, only: f_dump_buffer Definition ---------- Rendered from ``flib/f_utils.f90``; the C example is part of the type documentation in the source and is compiled and run by the ``dump_buffer`` regression (``tests/c-bindings/dump_buffer.c``). .. f:autotype:: f_dump_buffer Notes ----- .. rubric:: Binding ownership The C ``f90_f_dump_buffer_*`` functions and C++ ``Futile::FDumpBuffer`` constructors copy their input character storage. Copies and C++ assignments have independent storage: either object may be destroyed first, and changing the source does not change its copy. Each returned C handle must be freed exactly once; the C destructor takes its handle by value, so the caller's old handle remains invalid after freeing it. The C++ raw-handle constructor adopts ownership and must not be used to wrap the same handle twice. Initialize Futile before construction and destroy all objects before finalizing. .. rubric:: String constructor The string constructor copies bytes up to the C NUL terminator, excluding that terminator. Null and empty strings produce null payload pointers. It preserves the supplied ``ipos`` cursor metadata verbatim; this value is not the length of the input. The default empty constructor sets ``ipos=0``. .. rubric:: Fortran assignment Native Fortran assignment of this pointer-containing type remains shallow; Fortran callers retain responsibility for their own storage. .. rubric:: Prototype status and test coverage The active ``dump_buffer`` C/C++ regression uses a 16 KiB quoted YAML scalar, checks every copied byte, parses it with libyaml, and verifies mutation, both destruction orders, copy assignment, self-assignment and empty buffers. Its allocation-ledger check rejects remaining tracked buffer allocations. The optional ``f_write(buffer=...)`` branch remains an unfinished prototype; these tests validate binding storage and lifetime, not buffered YAML output or flushing. See also -------- * :doc:`f_subptr_str` -- borrowed character views of existing strings, without copying. * :doc:`f_sizeof` -- payload bytes of character storage. * :doc:`/memory` -- tracked allocation and the allocation ledger.