Wise&mystical  1.0
Project about Europe
Loading...
Searching...
No Matches
rmem.h File Reference
#include <inttypes.h>
#include <stdbool.h>
+ Include dependency graph for rmem.h:

Go to the source code of this file.

Classes

struct  MemNode
 
struct  AllocList
 
struct  Arena
 
struct  MemPool
 
struct  ObjPool
 
struct  BiStack
 

Macros

#define RMEMAPI
 rmem - raylib memory pool and objects pool More...
 
#define RMEM_VERSION   "v1.3"
 

Typedefs

typedef struct MemNode MemNode
 
typedef struct AllocList AllocList
 
typedef struct Arena Arena
 
typedef struct MemPool MemPool
 
typedef struct ObjPool ObjPool
 
typedef struct BiStack BiStack
 

Enumerations

enum  { MEMPOOL_BUCKET_SIZE = 8 , MEMPOOL_BUCKET_BITS = (sizeof(uintptr_t) >> 1) + 1 , MEM_SPLIT_THRESHOLD = sizeof(uintptr_t) * 4 }
 

Functions

RMEMAPI MemPool CreateMemPool (size_t bytes)
 
RMEMAPI MemPool CreateMemPoolFromBuffer (void *buf, size_t bytes)
 
RMEMAPI void DestroyMemPool (MemPool *mempool)
 
RMEMAPI void * MemPoolAlloc (MemPool *mempool, size_t bytes)
 
RMEMAPI void * MemPoolRealloc (MemPool *mempool, void *ptr, size_t bytes)
 
RMEMAPI void MemPoolFree (MemPool *mempool, void *ptr)
 
RMEMAPI void MemPoolCleanUp (MemPool *mempool, void **ptrref)
 
RMEMAPI void MemPoolReset (MemPool *mempool)
 
RMEMAPI size_t GetMemPoolFreeMemory (const MemPool mempool)
 
RMEMAPI ObjPool CreateObjPool (size_t objsize, size_t len)
 
RMEMAPI ObjPool CreateObjPoolFromBuffer (void *buf, size_t objsize, size_t len)
 
RMEMAPI void DestroyObjPool (ObjPool *objpool)
 
RMEMAPI void * ObjPoolAlloc (ObjPool *objpool)
 
RMEMAPI void ObjPoolFree (ObjPool *objpool, void *ptr)
 
RMEMAPI void ObjPoolCleanUp (ObjPool *objpool, void **ptrref)
 
RMEMAPI BiStack CreateBiStack (size_t len)
 
RMEMAPI BiStack CreateBiStackFromBuffer (void *buf, size_t len)
 
RMEMAPI void DestroyBiStack (BiStack *destack)
 
RMEMAPI void * BiStackAllocFront (BiStack *destack, size_t len)
 
RMEMAPI void * BiStackAllocBack (BiStack *destack, size_t len)
 
RMEMAPI void BiStackResetFront (BiStack *destack)
 
RMEMAPI void BiStackResetBack (BiStack *destack)
 
RMEMAPI void BiStackResetAll (BiStack *destack)
 
RMEMAPI intptr_t BiStackMargins (BiStack destack)
 

Macro Definition Documentation

◆ RMEM_VERSION

#define RMEM_VERSION   "v1.3"

Definition at line 58 of file rmem.h.

◆ RMEMAPI

#define RMEMAPI

rmem - raylib memory pool and objects pool

A quick, efficient, and minimal free list and arena-based allocator

PURPOSE:

  • A quicker, efficient memory allocator alternative to 'malloc' and friends.
  • Reduce the possibilities of memory leaks for beginner developers using Raylib.
  • Being able to flexibly range check memory if necessary.

CONFIGURATION:

#define RMEM_IMPLEMENTATION Generates the implementation of the library into the included file. If not defined, the library is in header only mode and can be included in other headers or source files without problems. But only ONE file should hold the implementation.

LICENSE: zlib/libpng

Copyright (c) 2019 Kevin 'Assyrianic' Yonan (@assyrianic) and reviewed by Ramon Santamaria (@raysan5)

This software is provided "as-is", without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software.

Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions:

  1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
  2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
  3. This notice may not be removed or altered from any source distribution.

Definition at line 55 of file rmem.h.

Typedef Documentation

◆ AllocList

typedef struct AllocList AllocList

◆ Arena

typedef struct Arena Arena

◆ BiStack

typedef struct BiStack BiStack

◆ MemNode

typedef struct MemNode MemNode

Definition at line 65 of file rmem.h.

◆ MemPool

typedef struct MemPool MemPool

◆ ObjPool

typedef struct ObjPool ObjPool

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
MEMPOOL_BUCKET_SIZE 
MEMPOOL_BUCKET_BITS 
MEM_SPLIT_THRESHOLD 

Definition at line 84 of file rmem.h.

Function Documentation

◆ BiStackAllocBack()

RMEMAPI void * BiStackAllocBack ( BiStack destack,
size_t  len 
)

◆ BiStackAllocFront()

RMEMAPI void * BiStackAllocFront ( BiStack destack,
size_t  len 
)

◆ BiStackMargins()

RMEMAPI intptr_t BiStackMargins ( BiStack  destack)

◆ BiStackResetAll()

RMEMAPI void BiStackResetAll ( BiStack destack)

◆ BiStackResetBack()

RMEMAPI void BiStackResetBack ( BiStack destack)

◆ BiStackResetFront()

RMEMAPI void BiStackResetFront ( BiStack destack)

◆ CreateBiStack()

RMEMAPI BiStack CreateBiStack ( size_t  len)

◆ CreateBiStackFromBuffer()

RMEMAPI BiStack CreateBiStackFromBuffer ( void *  buf,
size_t  len 
)

◆ CreateMemPool()

RMEMAPI MemPool CreateMemPool ( size_t  bytes)

◆ CreateMemPoolFromBuffer()

RMEMAPI MemPool CreateMemPoolFromBuffer ( void *  buf,
size_t  bytes 
)

◆ CreateObjPool()

RMEMAPI ObjPool CreateObjPool ( size_t  objsize,
size_t  len 
)

◆ CreateObjPoolFromBuffer()

RMEMAPI ObjPool CreateObjPoolFromBuffer ( void *  buf,
size_t  objsize,
size_t  len 
)

◆ DestroyBiStack()

RMEMAPI void DestroyBiStack ( BiStack destack)

◆ DestroyMemPool()

RMEMAPI void DestroyMemPool ( MemPool mempool)

◆ DestroyObjPool()

RMEMAPI void DestroyObjPool ( ObjPool objpool)

◆ GetMemPoolFreeMemory()

RMEMAPI size_t GetMemPoolFreeMemory ( const MemPool  mempool)

◆ MemPoolAlloc()

RMEMAPI void * MemPoolAlloc ( MemPool mempool,
size_t  bytes 
)

◆ MemPoolCleanUp()

RMEMAPI void MemPoolCleanUp ( MemPool mempool,
void **  ptrref 
)

◆ MemPoolFree()

RMEMAPI void MemPoolFree ( MemPool mempool,
void *  ptr 
)

◆ MemPoolRealloc()

RMEMAPI void * MemPoolRealloc ( MemPool mempool,
void *  ptr,
size_t  bytes 
)

◆ MemPoolReset()

RMEMAPI void MemPoolReset ( MemPool mempool)

◆ ObjPoolAlloc()

RMEMAPI void * ObjPoolAlloc ( ObjPool objpool)

◆ ObjPoolCleanUp()

RMEMAPI void ObjPoolCleanUp ( ObjPool objpool,
void **  ptrref 
)

◆ ObjPoolFree()

RMEMAPI void ObjPoolFree ( ObjPool objpool,
void *  ptr 
)