1/******************************************************************************/
2#ifdef JEMALLOC_H_TYPES
3
4typedef struct quarantine_obj_s quarantine_obj_t;
5typedef struct quarantine_s quarantine_t;
6
7/* Default per thread quarantine size if valgrind is enabled. */
8#define	JEMALLOC_VALGRIND_QUARANTINE_DEFAULT	(ZU(1) << 24)
9
10#endif /* JEMALLOC_H_TYPES */
11/******************************************************************************/
12#ifdef JEMALLOC_H_STRUCTS
13
14struct quarantine_obj_s {
15	void	*ptr;
16	size_t	usize;
17};
18
19struct quarantine_s {
20	size_t			curbytes;
21	size_t			curobjs;
22	size_t			first;
23#define	LG_MAXOBJS_INIT 10
24	size_t			lg_maxobjs;
25	quarantine_obj_t	objs[1]; /* Dynamically sized ring buffer. */
26};
27
28#endif /* JEMALLOC_H_STRUCTS */
29/******************************************************************************/
30#ifdef JEMALLOC_H_EXTERNS
31
32quarantine_t	*quarantine_init(size_t lg_maxobjs);
33void	quarantine(void *ptr);
34void	quarantine_cleanup(void *arg);
35bool	quarantine_boot(void);
36
37#endif /* JEMALLOC_H_EXTERNS */
38/******************************************************************************/
39#ifdef JEMALLOC_H_INLINES
40
41#ifndef JEMALLOC_ENABLE_INLINE
42malloc_tsd_protos(JEMALLOC_ATTR(unused), quarantine, quarantine_t *)
43
44void	quarantine_alloc_hook(void);
45#endif
46
47#if (defined(JEMALLOC_ENABLE_INLINE) || defined(JEMALLOC_QUARANTINE_C_))
48malloc_tsd_externs(quarantine, quarantine_t *)
49malloc_tsd_funcs(JEMALLOC_ALWAYS_INLINE, quarantine, quarantine_t *, NULL,
50    quarantine_cleanup)
51
52JEMALLOC_ALWAYS_INLINE void
53quarantine_alloc_hook(void)
54{
55	quarantine_t *quarantine;
56
57	assert(config_fill && opt_quarantine);
58
59	quarantine = *quarantine_tsd_get();
60	if (quarantine == NULL)
61		quarantine_init(LG_MAXOBJS_INIT);
62}
63#endif
64
65#endif /* JEMALLOC_H_INLINES */
66/******************************************************************************/
67
68