chromium/components/gwp_asan/client/lightweight_detector/malloc_shims.h

// Copyright 2023 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef COMPONENTS_GWP_ASAN_CLIENT_LIGHTWEIGHT_DETECTOR_MALLOC_SHIMS_H_
#define COMPONENTS_GWP_ASAN_CLIENT_LIGHTWEIGHT_DETECTOR_MALLOC_SHIMS_H_

#include <stddef.h>

#include "base/memory/raw_ptr_exclusion.h"
#include "build/build_config.h"
#include "components/gwp_asan/client/export.h"
#include "components/gwp_asan/client/gwp_asan.h"

namespace gwp_asan::internal::lud {

// `free()`-like functions that we support. Each value should have a
// corresponding branch in `ResumeFree()`.
enum class FreeFunctionKind : uint8_t {};

struct AllocationInfo {};

GWP_ASAN_EXPORT void InstallMallocHooks(size_t max_allocation_count,
                                        size_t max_total_size,
                                        size_t total_size_high_water_mark,
                                        size_t total_size_low_water_mark,
                                        size_t eviction_chunk_size,
                                        size_t eviction_task_interval_ms,
                                        size_t sampling_frequency);

// `RandomEvictionQuarantine` needs to defer calling the next hook
// in the allocator shim chain. Not for general use.
GWP_ASAN_EXPORT void FinishFree(const AllocationInfo&);

}  // namespace gwp_asan::internal::lud

#endif  // COMPONENTS_GWP_ASAN_CLIENT_LIGHTWEIGHT_DETECTOR_MALLOC_SHIMS_H_