blob: 454bcc3020e8bc245464a177357c03d383d7ed18 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
#pragma once
#ifndef CACHED_H_
#define CACHED_H_
#include <stddef.h>
/**
* Create cache of size `slots` for allocating chunks of `object_size` bytes.
* Return 0 on success, <0 on failure.
*/
int
ca_setup(size_t object_size, size_t slots);
/**
* Allocate a chunk of memory.
* Return NULL on failure.
*/
void *
ca_alloc(void);
/**
* Free a chunk of memory obtained from `ca_alloc`.
*/
void
ca_free(void *object);
/**
* Destroy the cache, freeing all memory still allocated.
*/
void
ca_cleanup(void);
#endif
|