reldb 0.1.0
Recreational SQLite
Loading...
Searching...
No Matches
inputbuffer.c File Reference

Implementation of the InputBuffer and I/O functions. More...

#include "inputbuffer.h"
Include dependency graph for inputbuffer.c:

Go to the source code of this file.

Functions

InputBuffernew_input_buffer (void)
 Allocates and initializes a new InputBuffer.
ssize_t getline (char **lineptr, size_t *n, FILE *stream)
 Reads an entire line from a stream into a dynamically resizing buffer.
void read_input (InputBuffer *input_buffer)
 Reads a line of input from standard input into the buffer.
void close_input_buffer (InputBuffer *input_buffer)
 Frees the memory associated with an InputBuffer.

Detailed Description

Implementation of the InputBuffer and I/O functions.

Definition in file inputbuffer.c.

Function Documentation

◆ close_input_buffer()

void close_input_buffer ( InputBuffer * input_buffer)

Frees the memory associated with an InputBuffer.

Parameters
[in]input_bufferThe buffer to free. Must not be NULL.

Definition at line 72 of file inputbuffer.c.

Here is the caller graph for this function:

◆ getline()

ssize_t getline ( char ** lineptr,
size_t * n,
FILE * stream )

Reads an entire line from a stream into a dynamically resizing buffer.

Parameters
[in,out]lineptrPointer to the character buffer pointer.
[in,out]nPointer to the size of the allocated buffer.
[in]streamThe file stream to read from (e.g., stdin).
Returns
The number of characters read, or -1 on EOF or error.

Definition at line 24 of file inputbuffer.c.

Here is the caller graph for this function:

◆ new_input_buffer()

InputBuffer * new_input_buffer ( void )

Allocates and initializes a new InputBuffer.

Creates a fresh InputBuffer struct on the heap, setting its pointers to NULL and lengths to 0.

Returns
A pointer to the newly allocated InputBuffer.

Definition at line 9 of file inputbuffer.c.

◆ read_input()

void read_input ( InputBuffer * input_buffer)

Reads a line of input from standard input into the buffer.

Wraps getline to safely read from stdin. It also strips the trailing newline character and updates the input_length property. Exits the program automatically if reading fails.

Parameters
[in,out]input_bufferThe buffer to read data into.

Definition at line 56 of file inputbuffer.c.

Here is the call graph for this function: