-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtralloc.h
More file actions
35 lines (24 loc) · 773 Bytes
/
tralloc.h
File metadata and controls
35 lines (24 loc) · 773 Bytes
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
/* See README.md for documentation
*
* IMPORTANT: Any `ptr` value used *must* be allocated by
* tralloc or you'll run into problems.
*/
#ifndef TRALLOC
#define TRALLOC
#include <stdlib.h>
#include <assert.h>
/* num. bytes heap-allocated by tralloc */
size_t tr_siz();
/* the max. number of heap-allocated bytes tralloc will allow */
size_t tr_limit();
/* set the max. number of heap-allocated bytes tralloc will allow, 0 = infinite */
size_t tr_setlimit(size_t n);
/* The number of bytes allocated for `ptr` */
size_t tr_allocsiz(void *ptr);
/* stdlib wrappers
* These behave the same as their stdlib counterparts */
void *tr_malloc(size_t n);
void *tr_calloc(size_t num, size_t n);
void *tr_realloc(void *ptr, size_t n);
void tr_free(void *ptr);
#endif