lsquic_malo.h revision c51ce338
1/* Copyright (c) 2017 LiteSpeed Technologies Inc.  See LICENSE. */
2/*
3 * lsquic_malo.h -- Fast allocator for fixed-sized objects.
4 */
5
6#ifndef LSQUIC_MALO_H
7#define LSQUIC_MALO_H 1
8
9struct malo;
10
11/* Create a malo allocator for objects of size `obj_size'. */
12struct malo *
13lsquic_malo_create (size_t obj_size);
14
15/* Get a new object. */
16void *
17lsquic_malo_get (struct malo *);
18
19/* Return obj to the pool */
20void
21lsquic_malo_put (void *obj);
22
23/* This deallocates all remaining objects. */
24void
25lsquic_malo_destroy (struct malo *);
26
27/* The iterator is built-in.  Usage:
28 * void *obj;
29 * for (obj = lsquic_malo_first(obj); obj; lsquic_malo_next(obj))
30 *     do_stuff(obj);
31 */
32void *
33lsquic_malo_first (struct malo *);
34
35void *
36lsquic_malo_next (struct malo *);
37
38size_t
39lsquic_malo_mem_used (const struct malo *);
40
41#endif
42