blob: 0d9ead241ce7096378d383156c50f728db32ce23 (
plain)
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
35
36
37
38
|
/* Copyright (c) 2008-2021, The Tor Project, Inc. */
/* See LICENSE for licensing information */
/**
* \file memarea.h
*
* \brief Header for memarea.c
**/
#ifndef TOR_MEMAREA_H
#define TOR_MEMAREA_H
#include <stddef.h>
typedef struct memarea_t memarea_t;
memarea_t *memarea_new(void);
void memarea_drop_all_(memarea_t *area);
/** @copydoc memarea_drop_all_
*
* Additionally, set <b>area</b> to NULL. */
#define memarea_drop_all(area) \
do { \
memarea_drop_all_(area); \
(area) = NULL; \
} while (0)
void memarea_clear(memarea_t *area);
int memarea_owns_ptr(const memarea_t *area, const void *ptr);
void *memarea_alloc(memarea_t *area, size_t sz);
void *memarea_alloc_zero(memarea_t *area, size_t sz);
void *memarea_memdup(memarea_t *area, const void *s, size_t n);
char *memarea_strdup(memarea_t *area, const char *s);
char *memarea_strndup(memarea_t *area, const char *s, size_t n);
void memarea_get_stats(memarea_t *area,
size_t *allocated_out, size_t *used_out);
void memarea_assert_ok(memarea_t *area);
#endif /* !defined(TOR_MEMAREA_H) */
|