<commit_before>//===--- Allocator.h - Simple memory allocation abstraction -----*- C++ -*-===//
//
//                     The LLVM Compiler Infrastructure
//
// This file was developed by <NAME> and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file defines the MallocAllocator and BumpPtrAllocator interfaces.
//
//===----------------------------------------------------------------------===//

#ifndef LLVM_SUPPORT_ALLOCATOR_H
#define LLVM_SUPPORT_ALLOCATOR_H

#include <cstdlib>

namespace llvm {
    
class MallocAllocator {
public:
  MallocAllocator() {}
  ~MallocAllocator() {}
  
  void Reset() {}
  void *Allocate(unsigned Size, unsigned Alignment) { return malloc(Size); }
  void Deallocate(void *Ptr) { free(Ptr); }
  void PrintStats() const {}
};

/// BumpPtrAllocator - This allocator is useful for containers that need very
/// simple memory allocation strategies.  In particular, this just keeps
/// allocating memory, and never deletes it until the entire block is dead. This
/// makes allocation speedy, but must only be used when the trade-off is ok.
class BumpPtrAllocator {
  void *TheMemory;
public:
  BumpPtrAllocator();
  ~BumpPtrAllocator();
  
  void Reset();
  void *Allocate(unsigned Size, unsigned Alignment);
  void Deallocate(void *Ptr) {}<commit_msg>Added member template functions to MallocAllocator and BumpPtrAllocator that implement allocations that return a properly typed pointer.  For BumpPtrAllocator, the allocated memory is automatically aligned to the minimum alignment of the type (as calculated by llvm::AlignOf::Alignment).<commit_after>//===--- Allocator.h - Simple memory allocation abstraction -----*- C++ -*-===//
//
//                     The LLVM Compiler Infrastructure
//
// This file was developed by <NAME> and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file defines the MallocAllocator and BumpPtrAllocator interfaces.
//
//===----------------------------------------------------------------------===//

#ifndef LLVM_SUPPORT_ALLOCATOR_H
#define LLVM_SUPPORT_ALLOCATOR_H

#include "llvm/Support/AlignOf.h"
#include <cstdlib>

namespace llvm {
    
class MallocAllocator {
public:
  MallocAllocator() {}
  ~MallocAllocator() {}
  
  void Reset() {}
  void *Allocate(unsigned Size, unsigned Alignment) { return malloc(Size); }
  
  template <typename T>
  T* Allocate() { return reinterpret_cast<T*>(malloc(sizeof(T))); }
  
  void Deallocate(void *Ptr) { free(Ptr); }
  void PrintStats() const {}
};

/// BumpPtrAllocator - This allocator is useful for containers that need very
/// simple memory allocation strategies.  In particular, this just keeps
/// allocating memory, and never deletes it until the entire block is dead. This
/// makes allocation speedy, but must only be used when the trade-off is ok.
class BumpPtrAllocator {
  void *TheMemory;
public:
  BumpPtrAllocator();
  ~BumpPtrAllocator();
  
  void Reset();
  void *Allocate(unsigned Size, unsigned Alignment);

  template <typename T>
  T* Allocate() { 
    return reinterpret_cast<T*>(Allocate(sizeof(T),AlignOf<T>::Alignment));
  }

  
  void Deallocate(void *Ptr) {}
{'fraction_non_alphanumeric': 0.19387153800824986, 'fraction_numerical': 0.0, 'mean_word_length': 2.6117021276595747, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 12, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4801350', 'n_tokens_mistral': 910, 'n_tokens_neox': 889, 'n_words': 313}