MPD
Data Structures | Functions
page.h File Reference

This is a library which manages reference counted buffers. More...

#include <stddef.h>
#include <stdbool.h>

Go to the source code of this file.

Data Structures

struct  page
 A dynamically allocated buffer which keeps track of its reference count. More...
 

Functions

struct pagepage_new_copy (const void *data, size_t size)
 Creates a new page object, and copies data from the specified buffer.
 
struct pagepage_new_concat (const struct page *a, const struct page *b)
 Concatenates two pages to a new page.
 
void page_ref (struct page *page)
 Increases the reference counter.
 
bool page_unref (struct page *page)
 Decreases the reference counter.
 

Detailed Description

This is a library which manages reference counted buffers.

Definition in file page.h.

Function Documentation

struct page* page_new_concat ( const struct page a,
const struct page b 
)
read

Concatenates two pages to a new page.

Parameters
athe first page
bthe second page, which is appended
struct page* page_new_copy ( const void *  data,
size_t  size 
)
read

Creates a new page object, and copies data from the specified buffer.

It is initialized with a reference count of 1.

Parameters
datathe source buffer
sizethe size of the source buffer
Returns
the new page object
void page_ref ( struct page page)

Increases the reference counter.

Parameters
pagethe page object
bool page_unref ( struct page page)

Decreases the reference counter.

If it reaches zero, the page is freed.

Parameters
pagethe page object
Returns
true if the page has been freed