<commit_before>#pragma once
//License: Public Domain
//Author: elf
//EMail: <EMAIL>

//memory pool

#include <assert.h>
#include "Memory.h"

typedef struct struct_MPool_Node{
 struct struct_MPool_Node *pNext;
}MPool_Node;

typedef struct{
 size_t nObjectSize;
 Byte *pBegin;
 Byte *pEnd;
 Byte *pLast;
 MPool_Node *pUsedEntry;
 Byte *pForAlignment;
}MPool;

static inline void MPool_Initialize(MPool *pPool, Byte *pObjectBegin, Byte *pObjectEnd, U32 nObjects, size_t nObjectSize){
 assert(Memory_Aligned((size_t)pPool));
 assert(Memory_Aligned((size_t)pObjectBegin));
 assert(Memory_Aligned((size_t)pObjectEnd));
 assert(Memory_Aligned(nObjectSize));
 assert((pObjectBegin + nObjects * nObjectSize) == pObjectEnd);

 pPool->nObjectSize = nObjectSize;
 pPool->pBegin = pPool->pLast = pObjectBegin;
 pPool->pEnd = pObjectEnd;
 pPool->pUsedEntry = null;
}

//memory peak(bytes)
static inline size_t MPool_Peak(MPool *pPool){
 return pPool->pLast - pPool->pBegin;
}

static inline Bool MPool_UnusedEmpty(MPool *pPool){
 return pPool->pLast == pPool->pEnd;
}

static inline Bool MPool_UnusedNotEmpty(MPool *pPool){
 return pPool->pLast != pPool->pEnd;
}

static inline void *MPool_PopUnused(MPool *pPool){
  void *pObject = pPool->pLast;
  pPool->pLast += pPool->nObjectSize;
 return pObject;
}

static inline Bool MPool_UsedEmpty(MPool *pPool){
 return pPool->pUsedEntry == null;
}

static inline Bool MPool_UsedNotEmpty(MPool *pPool){
 return pPool->pUsedEntry != null;
}

static inline void *MPool_PopUsed(MPool *pPool){
  void *pObject = pPool->pUsedEntry;
  pPool->pUsedEntry = pPool->pUsedEntry->pNext;
 return pObject;
}

static inline void *MPool_Pop(MPool *pPool){<commit_msg>Add MPool's interfaces<commit_after>#pragma once
//License: Public Domain
//Author: elf
//EMail: <EMAIL>

//memory pool

#include <assert.h>
#include "Memory.h"

typedef struct struct_MPool_Node{
 struct struct_MPool_Node *pNext;
}MPool_Node;

typedef struct{
 size_t nObjectSize;
 Byte *pBegin;
 Byte *pEnd;
 Byte *pLast;
 MPool_Node *pUsedEntry;
 Byte *pForAlignment;
}MPool;

static inline void MPool_Initialize(MPool *pPool, Byte *pObjectBegin, Byte *pObjectEnd, U32 nObjects, size_t nObjectSize){
 assert(Memory_Aligned((size_t)pPool));
 assert(Memory_Aligned((size_t)pObjectBegin));
 assert(Memory_Aligned((size_t)pObjectEnd));
 assert(Memory_Aligned(nObjectSize));
 assert((pObjectBegin + nObjects * nObjectSize) == pObjectEnd);

 pPool->nObjectSize = nObjectSize;
 pPool->pBegin = pPool->pLast = pObjectBegin;
 pPool->pEnd = pObjectEnd;
 pPool->pUsedEntry = null;
}

//memory peak(bytes)
static inline size_t MPool_Peak(MPool *pPool){
 return pPool->pLast - pPool->pBegin;
}

static inline Bool MPool_UnusedEmpty(MPool *pPool){
 return pPool->pLast == pPool->pEnd;
}

static inline Bool MPool_UnusedNotEmpty(MPool *pPool){
 return pPool->pLast != pPool->pEnd;
}

static inline void *MPool_PopUnused(MPool *pPool){
  void *pObject = pPool->pLast;
  pPool->pLast += pPool->nObjectSize;
 return pObject;
}

static inline Bool MPool_UsedEmpty(MPool *pPool){
 return pPool->pUsedEntry == null;
}

static inline Bool MPool_UsedNotEmpty(MPool *pPool){
 return pPool->pUsedEntry != null;
}

static inline void *MPool_PopUsed(MPool *pPool){
  void *pObject = pPool->pUsedEntry;
  pPool->pUsedEntry = pPool->pUsedEntry->pNext;
 return pObject;
}

static inline Bool MPool_Empty(MPool *pPool){
 return MPool_UsedEmpty(pPool) && MPool_UnusedEmpty(pPool);
}

static inline Bool MPool_NotEmpty(MPool *pPool){
 return MPool_UsedNotEmpty(pPool) || MPool_UnusedNotEmpty(pPool);
}

static inline void *MPool_Pop(MPool *pPool){
{'fraction_non_alphanumeric': 0.12486095661846495, 'fraction_numerical': 0.0011123470522803114, 'mean_word_length': 6.094674556213017, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 47, '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': '1823205', 'n_tokens_mistral': 1328, 'n_tokens_neox': 1303, 'n_words': 293}