Code Monkey home page Code Monkey logo

malloc-free's Introduction

malloc-free

mem.h/mem.c contain the main functions that allocates and frees memory space. Mem_Alloc() is similar to the library function malloc(). Mem_Alloc takes as a parameter the size in bytes of the object to be allocated, and returns a pointer to the start of that object. If there is not enough contiguous free space within sizeOfRegion allocated by Mem_Init to fulfill the request NULL is returned. Mem_Alloc() returns 4-byte aligned chunks of memory. Mem_Malloc() starts at the begining of the memory and allocates the first free block which can accommodate the requested size. Mem_Free() takes in a pointer and frees the memory object that it points to. If the pointer was not allocated by Mem_Alloc(), or the pointer is NULL Mem_Free() will return -1. If it successfully frees the memory 0 is returned. Mem_Free() coalesces if one or both of the immediate neighbours are free.

The top level Makefile will produce libmem.so from mem.h/mem.c. In order to run any tests a current version of libmem.so needs to be in the tests directory.

The tests directory contains different scenarios or Mem_Alloc() and Mem_Free(). To see current statistics of the memory place Mem_Dump(); into the test file. En example is coalesce6.c. To compile the tests directory, use Makefile in that directory. testlist.txt explains all tests in the tests directory.

All files are compiled using: gcc -Wall -m32 -O

malloc-free's People

Contributors

mziemer21 avatar

Watchers

 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.