Files
mars-libowfat/buffer/buffer_init_staticcontents.3
leitner b7b8a0efc1 gcc 15 and C23 force some union trickery on buffer.h :-(
add a few buffer_init*_forread variants to pretend we have type safety
  make sure buffer_init_staticcontents handles flushing attempts
2025-04-22 09:32:03 +00:00

38 lines
1.1 KiB
Groff

.TH buffer_init_staticcontents 3
.SH NAME
buffer_init_staticcontents \- initialize buffer structure
.SH SYNTAX
.B #include <libowfat/buffer.h>
void \fBbuffer_init_staticcontents\fR(buffer &\fIb\fR,
char* \fIy\fR, size_t \fIylen\fR);
void \fBbuffer_init_staticcontents_forread\fR(buffer &\fIb\fR,
const char* \fIy\fR, size_t \fIylen\fR);
.SH DESCRIPTION
buffer_init_staticcontents sets up a buffer pointing to a fixed buffer.
No file is associated with the buffer. No resizing is done on the
buffer. Writing past capacity will return an error.
buffer_init_staticcontents_forread sets up a buffer for reading,
pointing to a pre-filled fixed buffer.
This is useful for writing unit tests.
.SH EXAMPLE
#include <libowfat/buffer.h>
#include <libowfat/byte.h>
#include <assert.h>
char buf[4096];
buffer output;
char x;
buffer_init_staticcontents(&output,buf,sizeof buf);
buffer_putsflush(&output,"foo\\nbar\\n");
assert(output.p==8 && byte_equal(buf,8,"foo\\nbar\\n"));
.SH "SEE ALSO"
buffer_init(3), buffer(3), buffer_init_write(3)