Skip to content

vasilybib1/myheap

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

My Heap

Small quick project based on what we learnt in class. Allows the user to create a heap memory with a specified size and then allows to store data on that heap with matadata. Then allows those blocks to be deallocated and merged later.

Usage

// creates a heap with 256 allocated bytes
struct myheap* h = heapCreate(256);

// allocates memory on that heap
int* arr1 = myheapMalloc(h, sizeof(int) * 5);
int* arr2 = myheapMalloc(h, sizeof(int) * 10);

// data modification
arr1[0] = 1;
arr1[1] = 2;
arr1[2] = 3;

arr2[3] = 3;
arr2[6] = 2;
arr2[9] = 1;

// frees the data
myheapFree(h, arr1);
myheapFree(h, arr2);

Useful Feature

printBlocks(h);

Shows the blocks allocated currently

MY-HEAP: 4306812928 - size: 240 - start: 4306812944
block: 0 - 4306812944 - size: 40 used: 1
block: 1 - 4306812984 - size: 56 used: 1
block: 2 - 4306813040 - size: 144 used: 0

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published