2012-04-06 15:35:09 +08:00
|
|
|
/******************************************************************************/
|
|
|
|
#ifdef JEMALLOC_H_TYPES
|
|
|
|
|
2013-01-31 07:03:11 +08:00
|
|
|
typedef struct quarantine_obj_s quarantine_obj_t;
|
|
|
|
typedef struct quarantine_s quarantine_t;
|
|
|
|
|
2012-04-06 15:35:09 +08:00
|
|
|
/* Default per thread quarantine size if valgrind is enabled. */
|
|
|
|
#define JEMALLOC_VALGRIND_QUARANTINE_DEFAULT (ZU(1) << 24)
|
|
|
|
|
|
|
|
#endif /* JEMALLOC_H_TYPES */
|
|
|
|
/******************************************************************************/
|
|
|
|
#ifdef JEMALLOC_H_STRUCTS
|
|
|
|
|
2013-01-31 07:03:11 +08:00
|
|
|
struct quarantine_obj_s {
|
|
|
|
void *ptr;
|
|
|
|
size_t usize;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct quarantine_s {
|
|
|
|
size_t curbytes;
|
|
|
|
size_t curobjs;
|
|
|
|
size_t first;
|
|
|
|
#define LG_MAXOBJS_INIT 10
|
|
|
|
size_t lg_maxobjs;
|
|
|
|
quarantine_obj_t objs[1]; /* Dynamically sized ring buffer. */
|
|
|
|
};
|
|
|
|
|
2012-04-06 15:35:09 +08:00
|
|
|
#endif /* JEMALLOC_H_STRUCTS */
|
|
|
|
/******************************************************************************/
|
|
|
|
#ifdef JEMALLOC_H_EXTERNS
|
|
|
|
|
2014-11-05 10:03:11 +08:00
|
|
|
void quarantine_alloc_hook_work(tsd_t *tsd);
|
2014-09-23 12:09:23 +08:00
|
|
|
void quarantine(tsd_t *tsd, void *ptr);
|
|
|
|
void quarantine_cleanup(tsd_t *tsd);
|
2012-04-06 15:35:09 +08:00
|
|
|
|
|
|
|
#endif /* JEMALLOC_H_EXTERNS */
|
|
|
|
/******************************************************************************/
|
|
|
|
#ifdef JEMALLOC_H_INLINES
|
|
|
|
|
2013-01-31 07:03:11 +08:00
|
|
|
#ifndef JEMALLOC_ENABLE_INLINE
|
|
|
|
void quarantine_alloc_hook(void);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if (defined(JEMALLOC_ENABLE_INLINE) || defined(JEMALLOC_QUARANTINE_C_))
|
|
|
|
JEMALLOC_ALWAYS_INLINE void
|
|
|
|
quarantine_alloc_hook(void)
|
|
|
|
{
|
2014-09-23 12:09:23 +08:00
|
|
|
tsd_t *tsd;
|
2013-01-31 07:03:11 +08:00
|
|
|
|
|
|
|
assert(config_fill && opt_quarantine);
|
|
|
|
|
2014-10-05 02:12:53 +08:00
|
|
|
tsd = tsd_fetch();
|
2014-11-05 10:03:11 +08:00
|
|
|
if (tsd_quarantine_get(tsd) == NULL)
|
|
|
|
quarantine_alloc_hook_work(tsd);
|
2013-01-31 07:03:11 +08:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2012-04-06 15:35:09 +08:00
|
|
|
#endif /* JEMALLOC_H_INLINES */
|
|
|
|
/******************************************************************************/
|
|
|
|
|