Skip to content

HyperWinX/LeakHelper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LeakHelper

Small library for removing all unwanted memory leaks, caused by forgetting to deallocate memory.

contributors last commit forks contributors contributors


Contents

About LeakHelper

Small library for removing all unwanted memory leaks, caused by memory allocators/deallocators.

Installation

  1. Download header and source file.
  2. Include header into your source file when you want to use it.
  3. Use!

Usage

Initialize listing

First, you need to initialize listing. To do so, execute function and pass maximum count of pointers program will use.

init_listing(4); // Allocate memory for 4 pointers

Allocating memory

You have two functions for allocating memory: lmalloc() and lcalloc(). All of them take exactly one argument - memory size, and return pointer. Don't forget to check if it's valid!

void* ptr1 = lmalloc(32); // Allocate raw memory block 32 bytes size
void* ptr2 = lcalloc(64); // Allocate zero'ed out memory block 64 bytes size

Freeing memory

There is one function to free pointer: lfree(). Works only with pointers created using lmalloc() or lcalloc().

lfree(ptr1);

Finish program

At the end of program (or function) you can put free_all() function to free all pointers created with library, and prevent memory leaks.

free_all();

Example

This is an example.

About

Simple library to help with annoying leaks

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages