Ruby 4.1.0dev (2026-03-28 revision 634707a7255f132eb486eaf57473925c288ef7bd)
Typedefs | Functions
buffer.h File Reference

(634707a7255f132eb486eaf57473925c288ef7bd)

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.

Definition in file buffer.h.

Typedef Documentation

◆ pm_buffer_t

typedef struct pm_buffer_t pm_buffer_t

A wrapper around a contiguous block of allocated memory.

Definition at line 18 of file buffer.h.

Function Documentation

◆ 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.

Definition at line 371 of file buffer.c.

◆ 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.

Definition at line 50 of file buffer.c.

◆ pm_buffer_new()

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.

Definition at line 30 of file buffer.c.

◆ 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.

Definition at line 42 of file buffer.c.