Skip to content
/ ctx Public

A basic context/arena/pool/[INSERT PREFERED NAME] single header library.

License

Notifications You must be signed in to change notification settings

lxmcf/ctx

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CTX

CTX is a basic modified STB-Style library for basic memory management using contexts/arenas.

Building Examples

Linux/MacOS Steps:

cc -Wall -Wextra -Isrc example/main.c -o application

./application

Windows Steps: *

cl /Feapplication.exe /I"src" example/main.c

.\application.exe

Note: All Windows testing was performed using PortableBuildTools and not tested using Visual Studio

Example Code

// main.c
#define CTX_IMPL
#include "ctx.h"

int main (void) {
    // Static Context
    Context ctx = new_context (1 KB);
    int* life   = context_alloc (&ctx, sizeof (int));
    *life       = 42;

    CTX_LOG ("[STATIC]: life    = %d\n", *life);

    // Temp Context
    int* unlucky = context_talloc (sizeof (int));
    *unlucky     = 13;

    CTX_LOG ("[TEMP]:   unlucky = %d\n", *unlucky);

    context_free (&ctx);
    context_tfree ();

    return 0;
}

About

A basic context/arena/pool/[INSERT PREFERED NAME] single header library.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Languages