Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

freemalloc

freemalloc saves all memory addresses that have been allocated using malloc or custom memory allocator to release them all using one function.

Example

/*
#define FREEMALLOC_MALLOC(size) custom_malloc(size)

#define FREEMALLOC_CALLOC(num, size) custom_calloc(num, size)

#define FREEMALLOC_REALLOC(ptr, new_size) custom_realloc(ptr, new_size)

#define FREEMALLOC_FREE(ptr) custom_free(ptr)
*/

#define FREEMALLOC_ADDR_CAPACITY 4 // number of allocations
#include "freemalloc.h"

int main(void)
{
	freemalloc_t fm;
	int* ptr1 = (int*)freemalloc_malloc(&fm, sizeof(int));
	int* ptr2 = (int*)freemalloc_malloc(&fm, sizeof(int));
	int* ptr3 = (int*)freemalloc_malloc(&fm, sizeof(int));
	int* ptr4 = (int*)freemalloc_malloc(&fm, sizeof(int));
	freemalloc_free_all(&fm);
	return 0;
}

License

This repo is released under the MIT License.

About

freemalloc saves all memory addresses that have been allocated using malloc or custom memory allocator to release them all using one function.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages