MPD

- Main Page
- Data Structures
- Files

- File List
- Globals

Data Structures | Functions

# src/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 page * | page_new_copy (const void *data, size_t size)
| Creates a new page object, and copies data from the specified buffer.
struct page * | page_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:

  a | the first page
  b | the 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:

  data | the source buffer
  size | the size of the source buffer

Returns:
  the new page object

void page_ref | ( | struct page * | page | ) |

Increases the reference counter.

Parameters:

  page | the page object

bool page_unref | ( | struct page * | page | ) |

Decreases the reference counter.

If it reaches zero, the page is freed.

Parameters:

  page | the page object

Returns:
  true if the page has been freed