<commit_before>#include <bit/memory/errors.hpp>

#include <atomic>
#include <iostream>
#include <cassert>

//-----------------------------------------------------------------------------
// Forward Declarations
//-----------------------------------------------------------------------------

namespace {

  //---------------------------------------------------------------------------
  // Default Handlers
  //---------------------------------------------------------------------------

  void default_leak_handler( const bit::memory::allocator_info& info,
                             const void* ptr,
                             std::ptrdiff_t size );


  void default_stomp_handler( const bit::memory::allocator_info& info,
                              const void* ptr,
                              std::ptrdiff_t size );

  void default_double_delete_handler( const bit::memory::allocator_info& info,
                                      const void* ptr,
                                      std::ptrdiff_t size );

  void default_out_of_memory_handler( const bit::memory::allocator_info& info,
                                      std::size_t size );

  //---------------------------------------------------------------------------
  // Static Entries
  //---------------------------------------------------------------------------

  using atomic_leak_handler_t          = std::atomic<bit::memory::leak_handler_t>;
  using atomic_stomp_handler_t         = std::atomic<bit::memory::stomp_handler_t>;
  using atomic_double_delete_handler_t = std::atomic<bit::memory::double_delete_handler_t>;
  using atomic_out_of_memory_handler_t = std::atomic<bit::memory::out_of_memory_handler_t>;

  atomic_leak_handler_t          g_leak_handler(&default_leak_handler);
  atomic_stomp_handler_t         g_stomp_handler(&default_stomp_handler);
  atomic_double_delete_handler_t g_double_delete_handler(&default_double_delete_handler);
  atomic_out_of_memory_handler_t g_out_of_memory_handler(&default_out_of_memory_handler);
}

//-----------------------------------------------------------------------------
// Leak Handler
//-----------------------------------------------------------------------------

bit::memory::leak_handler_t bit::memory::set_leak_handler( leak_handler_t f )
  noexcept
{
  return g_leak_handler.exchange( f ? f : &default_leak_handler );
}

//-----------------------------------------------------------------------------

bit::memory::leak_handler_t bit::memory::get_leak_handler()
  noexcept
{
  return g_leak_handler;
}

//-----------------------------------------------------------------------------
// Stomp Handler
//-----------------------------------------------------------------------------

bit::memory::stomp_handler_t bit::memory::set_stomp_handler( stomp_handler_t f )
  noexcept
{
  return g_stomp_handler.exchange( f ? f : &default_stomp_handler );
}

//-----------------------------------------------------------------------------

bit::memory::stomp_handler_t bit::memory::get_stomp_handler()
  noexcept
{
  return g_stomp_handler;
}

//-----------------------------------------------------------------------------
// Double Delete handlers
//-----------------------------------------------------------------------------

bit::memory::double_delete_handler_t
  bit::memory::set_double_delete_handler(double_delete_handler_t f)
  noexcept
{
  return g_double_delete_handler.exchange( f ? f : &default_double_delete_handler );
}

bit::memory::double_delete_handler_t bit::memory::get_double_delete_handler()
  noexcept
{
  return g_double_delete_handler;
}

//-----------------------------------------------------------------------------
// Out-of-memory handlers
//-----------------------------------------------------------------------------

bit::memory::out_of_memory_handler_t
  bit::memory::set_out_of_memory_handler(out_of_memory_handler_t f)
  noexcept
{
  return g_out_of_memory_handler.exchange( f ? f : &default_out_of_memory_handler );
}

bit::memory::out_of_memory_handler_t bit::memory::get_out_of_memory_handler()
  noexcept
{
  return g_out_of_memory_handler;
}

//-----------------------------------------------------------------------------
// Anonymous Definitions
//-----------------------------------------------------------------------------

namespace {

  void default_leak_handler( const bit::memory::allocator_info& info,
                             const void* ptr,
                             std::ptrdiff_t size )
  {
    std::cerr << "leak detected at address " << ptr << "\n"
              << size << " bytes leaked.\n";

    assert(false);
  }


  void default_stomp_handler( const bit::memory::allocator_info& info,
                              const void* ptr,
                              std::ptrdiff_t size )
  {
    std::cerr << "stomp detected at address " << ptr << "\n"
              << size << " bytes overwritten.\n";

    assert(false);
  }

  void default_double_delete_handler( const bit::memory::allocator_info& info,
                                      const void* ptr,
                                      std::ptrdiff_t size )
  {
    std::cerr << "double delete detected at address " << ptr << "\n"
              << size << " bytes double-deleted.\n";

    assert(false);
  }

  void default_out_of_memory_handler( const bit::memory::allocator_info& info,
                                      std::size_t size )
  {
    std::cerr << "out of memory with allocator '"
              << info.name()
              << "' at address " << info.address() << ".\n"
              << "requested allocation size: " << size << " bytes\n";

    assert(false);
  }

} // anonymous namespace
<commit_msg>Amended wording in default leak checker<commit_after>#include <bit/memory/errors.hpp>

#include <atomic>
#include <iostream>
#include <cassert>

//-----------------------------------------------------------------------------
// Forward Declarations
//-----------------------------------------------------------------------------

namespace {

  //---------------------------------------------------------------------------
  // Default Handlers
  //---------------------------------------------------------------------------

  void default_leak_handler( const bit::memory::allocator_info& info,
                             const void* ptr,
                             std::ptrdiff_t size );


  void default_stomp_handler( const bit::memory::allocator_info& info,
                              const void* ptr,
                              std::ptrdiff_t size );

  void default_double_delete_handler( const bit::memory::allocator_info& info,
                                      const void* ptr,
                                      std::ptrdiff_t size );

  void default_out_of_memory_handler( const bit::memory::allocator_info& info,
                                      std::size_t size );

  //---------------------------------------------------------------------------
  // Static Entries
  //---------------------------------------------------------------------------

  using atomic_leak_handler_t          = std::atomic<bit::memory::leak_handler_t>;
  using atomic_stomp_handler_t         = std::atomic<bit::memory::stomp_handler_t>;
  using atomic_double_delete_handler_t = std::atomic<bit::memory::double_delete_handler_t>;
  using atomic_out_of_memory_handler_t = std::atomic<bit::memory::out_of_memory_handler_t>;

  atomic_leak_handler_t          g_leak_handler(&default_leak_handler);
  atomic_stomp_handler_t         g_stomp_handler(&default_stomp_handler);
  atomic_double_delete_handler_t g_double_delete_handler(&default_double_delete_handler);
  atomic_out_of_memory_handler_t g_out_of_memory_handler(&default_out_of_memory_handler);
}

//-----------------------------------------------------------------------------
// Leak Handler
//-----------------------------------------------------------------------------

bit::memory::leak_handler_t bit::memory::set_leak_handler( leak_handler_t f )
  noexcept
{
  return g_leak_handler.exchange( f ? f : &default_leak_handler );
}

//-----------------------------------------------------------------------------

bit::memory::leak_handler_t bit::memory::get_leak_handler()
  noexcept
{
  return g_leak_handler;
}

//-----------------------------------------------------------------------------
// Stomp Handler
//-----------------------------------------------------------------------------

bit::memory::stomp_handler_t bit::memory::set_stomp_handler( stomp_handler_t f )
  noexcept
{
  return g_stomp_handler.exchange( f ? f : &default_stomp_handler );
}

//-----------------------------------------------------------------------------

bit::memory::stomp_handler_t bit::memory::get_stomp_handler()
  noexcept
{
  return g_stomp_handler;
}

//-----------------------------------------------------------------------------
// Double Delete handlers
//-----------------------------------------------------------------------------

bit::memory::double_delete_handler_t
  bit::memory::set_double_delete_handler(double_delete_handler_t f)
  noexcept
{
  return g_double_delete_handler.exchange( f ? f : &default_double_delete_handler );
}

bit::memory::double_delete_handler_t bit::memory::get_double_delete_handler()
  noexcept
{
  return g_double_delete_handler;
}

//-----------------------------------------------------------------------------
// Out-of-memory handlers
//-----------------------------------------------------------------------------

bit::memory::out_of_memory_handler_t
  bit::memory::set_out_of_memory_handler(out_of_memory_handler_t f)
  noexcept
{
  return g_out_of_memory_handler.exchange( f ? f : &default_out_of_memory_handler );
}

bit::memory::out_of_memory_handler_t bit::memory::get_out_of_memory_handler()
  noexcept
{
  return g_out_of_memory_handler;
}

//-----------------------------------------------------------------------------
// Anonymous Definitions
//-----------------------------------------------------------------------------

namespace {

  void default_leak_handler( const bit::memory::allocator_info& info,
                             const void* ptr,
                             std::ptrdiff_t size )
  {
    std::cerr << "leak discovered with allocator '"
              << info.name() << "': "
              << size << " bytes leaked at address " << ptr << "\n";

    assert(false);
  }


  void default_stomp_handler( const bit::memory::allocator_info& info,
                              const void* ptr,
                              std::ptrdiff_t size )
  {
    std::cerr << "stomp detected at address " << ptr << "\n"
              << size << " bytes overwritten.\n";

    assert(false);
  }

  void default_double_delete_handler( const bit::memory::allocator_info& info,
                                      const void* ptr,
                                      std::ptrdiff_t size )
  {
    std::cerr << "double delete detected at address " << ptr << "\n"
              << size << " bytes double-deleted.\n";

    assert(false);
  }

  void default_out_of_memory_handler( const bit::memory::allocator_info& info,
                                      std::size_t size )
  {
    std::cerr << "out of memory with allocator '"
              << info.name()
              << "' at address " << info.address() << ".\n"
              << "requested allocation size: " << size << " bytes\n";

    assert(false);
  }

} // anonymous namespace

{'fraction_non_alphanumeric': 0.32651991614255765, 'fraction_numerical': 0.0, 'mean_word_length': 1.2322090076038215, 'pattern_counts': {'":': 0, '<': 115, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 12, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4496807', 'n_tokens_mistral': 2827, 'n_tokens_neox': 2755, 'n_words': 472}