#include "arena.h"
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include <stdio.h>
#include <errno.h>
#include <sys/mman.h>
#include <unistd.h>
#include <libgen.h>
#include "util/abort.h"
Go to the source code of this file.
◆ _PS_ARENA_ALLOCATE
| #define _PS_ARENA_ALLOCATE |
( |
|
arena, |
|
|
|
n |
|
) |
| |
Value: do { \
_PSDebug("Exhausted arena virtual memory\n%s", ""); \
ps_exit(1); \
} \
arena->offset += n; \
if ((arena->offset & (arena->page_size - 1)) > 0) { \
const size_t new_size = (arena->offset + arena->page_size - 1) \
& -(arena->page_size); \
mprotect(arena->start, new_size, PROT_READ | PROT_WRITE); \
} \
} while (0)
#define PS_INITIAL_ARENA_MMAP
An allocation of 16MB per arena.
Definition at line 62 of file arena.c.
◆ _PSDebug
| #define _PSDebug |
( |
|
... | ) |
/* nothing */ |
◆ NUSED
| #define NUSED __attribute__((unused)) |
◆ arena_strndup()
| char * arena_strndup |
( |
enum ps_arena_domain |
arena, |
|
|
const char * |
str, |
|
|
size_t |
length |
|
) |
| |
◆ ps_arena_allocate()
◆ ps_arena_allocate_debug()
| void * ps_arena_allocate_debug |
( |
enum ps_arena_domain |
domain, |
|
|
size_t |
n, |
|
|
const char *file |
NUSED, |
|
|
const char *func |
NUSED, |
|
|
size_t line |
NUSED |
|
) |
| |
◆ ps_arena_close()
Destroys any allocated objects in the given arena.
If the arena is already closed, this function does nothing.
- Parameters
-
| domain | The arena to close. |
Definition at line 45 of file arena.c.
◆ ps_arena_open()
Initializes the given arena for allocation.
- Parameters
-
| domain | The arena to initialize. |
Definition at line 24 of file arena.c.
◆ arenas