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

// 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.

#include "components/gwp_asan/client/lightweight_detector/malloc_shims.h"

#include <limits>
#include <optional>

#include "base/check_op.h"
#include "base/compiler_specific.h"
#include "base/notreached.h"
#include "base/numerics/checked_math.h"
#include "components/gwp_asan/client/lightweight_detector/random_eviction_quarantine.h"
#include "components/gwp_asan/client/sampling_state.h"
#include "partition_alloc/shim/allocator_shim.h"

namespace gwp_asan::internal::lud {

namespace {

AllocatorDispatch;

extern AllocatorDispatch g_allocator_dispatch;

// By being implemented as a global with inline method definitions, method calls
// and member accesses are inlined and as efficient as possible in the
// performance-sensitive allocation hot-path.
SamplingState<LIGHTWEIGHTDETECTOR> sampling_state;

bool MaybeQuarantine(void* address,
                     std::optional<size_t> maybe_size,
                     void* context,
                     FreeFunctionKind kind) {}

void FreeFn(void* address, void* context) {}

void FreeDefiniteSizeFn(void* address, size_t size, void* context) {}

void TryFreeDefaultFn(void* address, void* context) {}

static void AlignedFreeFn(void* address, void* context) {}

AllocatorDispatch g_allocator_dispatch =;

}  // namespace

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) {}

void FinishFree(const AllocationInfo& allocation) {}

}  // namespace gwp_asan::internal::lud