Code Monkey home page Code Monkey logo

allocator's Introduction

This is a modern refactoring of the simple "storage allocator" found in the classic K&R TCPL book.

It retains the simplicity and efficiency of the original, adding a few improvements :

  • Localised, encapsulated state :

    The K&R allocator uses a global freelist, so there is one global allocator. Instead, we load/store the freelist and other state in struct allocators, so there may be any number of independent, scope-bound allocator objects.

  • Custom memory pools :

    Where the original obtains memory from the OS through a syscall, here the user adds memory region(s) to an allocator object via allocator_add().

  • Safe, correct & portable :

    This allocator is thread-safe using lightweight syncronisation techniques - spinlocks composed of C11 atomics.

    It also checks for integer overflow and treats this as an allocation error and handles alignment in a machine-independant way. In fact, the library is virtually freestanding.

  • Queryable :

    Like most modern allocators, this one too can query the real size of an allocation, with allocator_allocsz(). It also allows for querying each block's size in the freelist using allocator_for_blocks(). The K&R allocator is, in contrast, entirely opaque.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.