Skip to content

A C implementation of a heap management system for efficient dynamic memory allocation and deallocation, featuring error handling and memory usage inspection.

Notifications You must be signed in to change notification settings

SuryaAnything/Heap-Management-System

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Heap Management System

This project implements a heap management system in C, providing functionalities for dynamic memory allocation, deallocation, and memory usage inspection.

Contents

  1. Introduction
  2. Components
  3. Memory Management Functions
  4. Error Handling
  5. Usage

Introduction

The heap management system consists of a header file (cHEAP.h) and an implementation file (cHEAP.c). It includes functionalities to allocate, deallocate, and inspect memory blocks within a fixed-size memory pool.

Components

  • Header File (cHEAP.h):

    • Defines constants, data types, and function prototypes.
    • Contains macros for error handling.
  • Implementation File (cHEAP.c):

    • Implements memory management functions.
    • Defines a fixed-size memory pool and free list for managing memory blocks.

Memory Management Functions

  1. _initializer_(): Initializes the heap.
  2. cHEAP_AllocateNew(): Allocates memory blocks.
  3. cHEAP_Release(): Deallocates memory blocks.
  4. cHEAP_InspectFreeSpace(): Prints information about free memory blocks.
  5. cHEAP_Length(): Gets the size of an allocated memory block.
  6. cHEAP_IfAllocatable(): Checks if memory of a given size can be allocated.
  7. cHEAP_Nullify(): Nullifies memory contents.
  8. cHEAP_GetTotalFreeSpace(): Gets total free space in the heap.
  9. cHEAP_GetTotalAllocatedSpace(): Gets total allocated space in the heap.
  10. cHEAP_DeallocateAll(): Deallocates all memory blocks in the heap.

Error Handling

The system includes error handling mechanisms using errno and custom error messages for scenarios like segmentation faults, non-accessible memory, attempted deallocation of already freed memory, and illegal memory access.

Usage

To use the heap management system, include the cHEAP.h header file in your project and link it with the cHEAP.c implementation file. Then, you can call the provided memory management functions as needed.

About

A C implementation of a heap management system for efficient dynamic memory allocation and deallocation, featuring error handling and memory usage inspection.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published