Skip to content
/ Malloc Public

Re-implementing the Iconic C Memory Allocator

Notifications You must be signed in to change notification settings

A-Mahla/Malloc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

41 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Malloc - My Unique Take on the Classic C Allocator

mybadge

This project is about implementing a dynamic memory allocation mechanism.

🔧 System Requirements:

  • Operating System: Linux 64_X86 Distribution / MacOS
  • Software: make, gcc,

Usage

To run the command, open your terminal and follow these steps:

  • To create the dynamic Librairie libft_malloc.so:

    (cd /path/to/project/directory && make)
  • To run Units Tests with my malloc allocator:

    (cd /path/to/project/directory && make run)
  • To run same Units Tests with the original malloc:

    (cd /path/to/project/directory && make run_libc)

About

This custom C implementation of the malloc library functions is functional but not really optimized. This serves primarily as a proof of concept. Let's take a look at the implementation in the src file. It creates the shared library libft_malloc.so which can be used to replace malloc in all system commands.

To use my implementation on your program:

(export LD_LIBRARY_PATH=/path/to/project/directory && export LD_PRELOAD=libft_malloc.so && <program> )

It exposes the following methods:

void *malloc(size_t size);
void free(void *ptr);
void *realloc(void *ptr, size_t size);
void *calloc(size_t count, size_t size);
void show_alloc_mem(void); // Print informations about allocated zones

About

Re-implementing the Iconic C Memory Allocator

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published