libxtc
0.4.0
Async concurrency for C: Tokio + Seastar + BEAM, in one library
Loading...
Searching...
No Matches
xtc_alloc_audit.h
1
/*-
2
* Copyright (c) 2026, The XTC Project
3
* Use of this source code is governed by the ISC License.
4
*
5
* src/inc/xtc_alloc_audit.h
6
* Debug allocation auditor. When enabled it wraps the allocator
7
* vtable, recording every live allocation together with the
8
* process (xtc_self) that made it, so a test can assert that a
9
* process freed everything it allocated before it died -- per-proc
10
* leak detection. Off by default; it serializes alloc/free on a
11
* global mutex, so it is a debug/test tool, not for production.
12
*/
13
14
#ifndef XTC_ALLOC_AUDIT_H
15
#define XTC_ALLOC_AUDIT_H
16
17
#include <stddef.h>
18
#include <stdint.h>
19
20
#include "xtc_proc.h"
21
22
#ifdef __cplusplus
23
extern
"C"
{
24
#endif
25
26
/*
27
* PUBLIC: int xtc_alloc_audit_enable __P((int));
28
* PUBLIC: void xtc_alloc_audit_stats __P((size_t *, size_t *));
29
* PUBLIC: void xtc_alloc_audit_proc_leaks __P((xtc_pid_t, size_t *, size_t *));
30
*/
31
32
/* Enable (on != 0) or disable the auditor. Enabling wraps the
33
* current allocator hook; disabling restores it. Returns XTC_OK, or
34
* XTC_E_NOMEM if the tracking table could not be allocated. */
35
int
xtc_alloc_audit_enable(
int
on);
36
37
/* Total live (unfreed) allocations and their byte sum across all
38
* owners. Either pointer may be NULL. */
39
void
xtc_alloc_audit_stats(
size_t
*out_count,
size_t
*out_bytes);
40
41
/* Live allocations still attributed to process `pid` (allocations
42
* made off a process are attributed to the none pid). Either output
43
* pointer may be NULL. This is the per-proc leak check: call it from
44
* the process's xtc_proc_at_exit hook or after it is reaped. */
45
void
xtc_alloc_audit_proc_leaks(
xtc_pid_t
pid,
size_t
*out_count,
46
size_t
*out_bytes);
47
48
#ifdef __cplusplus
49
}
50
#endif
51
52
#endif
/* XTC_ALLOC_AUDIT_H */
xtc_pid_t
Definition
xtc_proc.h:33
src
inc
xtc_alloc_audit.h
Generated by
1.9.8