Giter Site home page Giter Site logo

malloc-1's Introduction

Linked List-based Malloc

How it works

This is a simple implementation of malloc() and free(). It uses a first fit approach, backed by a linked list. That is, whenever free() is called, it stores the newly freed memory fragments in a linked list sorted by memory address and merges fragments which are adjacent in memory. Then when malloc() is called, it first scans this list for an available memory fragment. If none is found, it issues a request to the kernel to allocate another piece of memory for it.

Building and running

The static object (.so) library can be built simply by running

make

There are no external dependencies. Running make produces libmalloc.so, which can be used in another process by executing e.g.

env LD_PRELOAD="./libmalloc.so" ls

Replace ls with the command you want to run. Alternately, you can use your libmalloc.so for everything by executing

export LD_PRELOAD="/path/to/libmalloc.so"

To switch back to the standard library, issue

export LD_PRELOAD=""

Testing

A test script, test.sh, has been provided. This script simply runs a unit test with the custom malloc library preloaded, as well as ls --color=auto. The script can be easily modified to test other commands.

malloc-1's People

Stargazers

Alexey Leonov avatar

Watchers

Prashanth Basappa 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.