<commit_before>#pragma once

#ifndef ZEKKU_POOL_H
#define ZEKKU_POOL_H
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <algorithm>
#include <random>
#include <type_traits>

namespace zekku {
  template<typename T>
  T* tmalloc(size_t elems) {
    return (T*) ::malloc(elems * sizeof(T));
  }
  template<typename T>
  T* trealloc(T* p, size_t elems) {
    return (T*) ::realloc(p, elems * sizeof(T));
  }
  constexpr size_t START_CAPAT = 64;
  template<typename T>
  class Pool {
  public:
    static_assert(std::is_trivially_copyable<T>::value,
      "Your T is not trivially copyable, dum dum!");
    Pool() : filled(0), capacity(START_CAPAT),
        elems(tmalloc<T>(START_CAPAT)),
        allocated(tmalloc<bool>(START_CAPAT)) {
      r.seed(time(nullptr));
      memset(allocated, 0, START_CAPAT * sizeof(bool));
    }
    ~Pool() { delete[] elems; delete[] allocated; }
    Pool(const Pool& other) = delete;
    Pool& operator=(const Pool& other) = delete;
    Pool& operator=(Pool&& other) {
      std::swap(filled, other.filled);
      std::swap(capacity, other.capacity);
      std::swap(elems, other.elems);
      std::swap(allocated, other.allocated);
      return *this;
    }
    T& get(size_t handle) { return elems[handle]; }
    template<typename... Args>
    size_t allocate(Args&&... args) {<commit_msg>Use free() in Pool instead of delete[]<commit_after>#pragma once

#ifndef ZEKKU_POOL_H
#define ZEKKU_POOL_H
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <algorithm>
#include <random>
#include <type_traits>

namespace zekku {
  template<typename T>
  T* tmalloc(size_t elems) {
    return (T*) ::malloc(elems * sizeof(T));
  }
  template<typename T>
  T* trealloc(T* p, size_t elems) {
    return (T*) ::realloc(p, elems * sizeof(T));
  }
  constexpr size_t START_CAPAT = 64;
  template<typename T>
  class Pool {
  public:
    static_assert(std::is_trivially_copyable<T>::value,
      "Your T is not trivially copyable, dum dum!");
    Pool() : filled(0), capacity(START_CAPAT),
        elems(tmalloc<T>(START_CAPAT)),
        allocated(tmalloc<bool>(START_CAPAT)) {
      r.seed(time(nullptr));
      memset(allocated, 0, START_CAPAT * sizeof(bool));
    }
    ~Pool() { ::free(elems); ::free(allocated); }
    Pool(const Pool& other) = delete;
    Pool& operator=(const Pool& other) = delete;
    Pool& operator=(Pool&& other) {
      std::swap(filled, other.filled);
      std::swap(capacity, other.capacity);
      std::swap(elems, other.elems);
      std::swap(allocated, other.allocated);
      return *this;
    }
    T& get(size_t handle) { return elems[handle]; }
    template<typename... Args>
    size_t allocate(Args&&... args) {
{'fraction_non_alphanumeric': 0.15676266861100985, 'fraction_numerical': 0.002916514764855997, 'mean_word_length': 3.822495606326889, 'pattern_counts': {'":': 0, '<': 31, '<?xml version=': 0, '>': 31, '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': '73008', 'n_tokens_mistral': 994, 'n_tokens_neox': 979, 'n_words': 220}