Git Product home page Git Product logo

lc4malloc's Introduction

LC4Malloc

Provides a dynamic memory manager for PennSim. The malloc implementation based on a first fit algorithm.

mallocV1 - first version (first fit) | Binaries - files required to link malloc library to the c program | Example - example of a fully linked malloc library | Implementation - the malloc c implementation file

How to link the malloc library to your c program (using malloc_test as an example)

Setup script files

Go to your script file (in my case, malloc_test.txt) and link the malloc file by:

  • Change (as malloc_test user lc4libc malloc_test) to (as malloc_test malloc user lc4libc malloc_test)
  • Add (break set OS_START) at the end

Include malloc.h

In your .c file (in my case, malloc_test.c), and include malloc.h, so lcc can see the prototypes for heap functions (#include "malloc.h")

Call initialize_heap

In your .c file, in main() function, call intialize_heap() (Not calling this function first will cause your program to access illegal memory!!!) int main() { intialize_heap(); ... }

And now, you're good to go!

======

Usage

Download the binary and link it with your current c file by including "malloc.h"

Known Bugs

- Free does not merge top chunk and the chunk before it

Todos

+ Check for negative size malloc

Contributors

Henry Zhu

Contributors on GitHub

Third party libraries

  • LCC, PennSim-Debugger

License

Version

  • Version 0.1

Contact

lc4malloc's People

Contributors

maknee avatar

Watchers

 avatar  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.