Prism Ruby parser
Loading...
Searching...
No Matches
Typedefs | Functions
buffer.h File Reference

A wrapper around a contiguous block of allocated memory. More...

#include "prism/compiler/exported.h"
#include "prism/compiler/nodiscard.h"
#include "prism/compiler/nonnull.h"
#include <stddef.h>
Include dependency graph for buffer.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Typedefs

typedef struct pm_buffer_t pm_buffer_t
 A wrapper around a contiguous block of allocated memory.
 

Functions

PRISM_EXPORTED_FUNCTION PRISM_NODISCARD pm_buffer_tpm_buffer_new (void)
 Allocate and initialize a new buffer.
 
PRISM_EXPORTED_FUNCTION void pm_buffer_free (pm_buffer_t *buffer) PRISM_NONNULL(1)
 Free both the memory held by the buffer and the buffer itself.
 
PRISM_EXPORTED_FUNCTION char * pm_buffer_value (const pm_buffer_t *buffer) PRISM_NONNULL(1)
 Return the value of the buffer.
 
PRISM_EXPORTED_FUNCTION size_t pm_buffer_length (const pm_buffer_t *buffer) PRISM_NONNULL(1)
 Return the length of the buffer.
 

Detailed Description

A wrapper around a contiguous block of allocated memory.

Function Documentation

◆ pm_buffer_new()

PRISM_EXPORTED_FUNCTION PRISM_NODISCARD pm_buffer_t * pm_buffer_new ( void  )

Allocate and initialize a new buffer.

If the buffer cannot be allocated, this function will abort the process.

Returns
A pointer to the initialized buffer. The caller is responsible for freeing the buffer with pm_buffer_free.

◆ pm_buffer_free()

PRISM_EXPORTED_FUNCTION void pm_buffer_free ( pm_buffer_t buffer)

Free both the memory held by the buffer and the buffer itself.

Parameters
bufferThe buffer to free.

◆ pm_buffer_value()

PRISM_EXPORTED_FUNCTION char * pm_buffer_value ( const pm_buffer_t buffer)

Return the value of the buffer.

Parameters
bufferThe buffer to get the value of.
Returns
The value of the buffer.

◆ pm_buffer_length()

PRISM_EXPORTED_FUNCTION size_t pm_buffer_length ( const pm_buffer_t buffer)

Return the length of the buffer.

Parameters
bufferThe buffer to get the length of.
Returns
The length of the buffer.