Giter VIP home page Giter VIP logo

kr-malloc's Introduction

K&R malloc

There is a very simple free list-based implementation of malloc in The C Programming Language, 2nd edition, by Brian Kernighan and Dennis Ritchie (“K&R”). Because it’s 🦃 Holiday Season 🎄 and I am taking time off, I decided to play around with it.

original_kr_malloc*

This is the malloc implementation from pp. 185 – 189 of K&R. I have tried to transcribe it exactly, even down to the spacing of the end-of-line comments.

To build on a modern system, I had to make a few trivial adjustments.

modern_kr_malloc*

This is a fairly faithful version of K&R, but which replaces sbrk with mmap, uses C’s type system somewhat better (it is -Weverything-clean), and does a bit of style cleanup.

arena_malloc*

This version parameterizes the global state in the 2 previous versions by making an Arena object an explicit argument to all functions in the public interface. This enables various interesting enhancements to the API and to the implementation.

kr-malloc's People

Watchers

Chris Palmer avatar  avatar

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.