Skip to content

C garbage collector, storing any malloc in a hash_table, resulting in a easier free, preventing any memory leaks during 42 School projects.

Notifications You must be signed in to change notification settings

nullswan/c_garbage_collector

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

c_garbage_collector

.github/workflows/norminette.yml
.github/workflows/tests.yml
Codacy Badge

usage

#include "includes/gcollector.h"

int	main(void)
{
	void	*ptr;

	// gc_new(100); - gc malloc bucket environnement start size
	ptr = galloc(100);
	// ptr = 0xMEMADDR;
	gfree(ptr);
	// ptr = 0;
	for (int i = 0; i < 100; i++)
		ptr = galloc(100);
	gc_destroy();
}

int	main(void)
{
	void	*ptr;

	// gc_new(100); - gc malloc bucket environnement start size
	ptr = galloc(100);
	// ptr = 0xMEMADDR;
	gree(ptr);
	// ptr = 0xMEMADDR;
	for (int i = 0; i < 100; i++)
		ptr = galloc(100);
	gc_destroy();
}

required header

#include "includes/gcollector.h"

data types

view_hashtable

default methods

// free mem, destroy node and set *ptr to 0.
bool	gfree(void **ptr);

// free mem, destroy node.
bool	gree(void *ptr);

// allocate mem, create node.
void	*galloc(size_t size);

published methods

t_hashtable	*gc_new(unsigned int size);
bool		gc_destroy(void);
t_hashtable	**gc_anchor(void);
bool		gc_anchor_exist(void);

About

C garbage collector, storing any malloc in a hash_table, resulting in a easier free, preventing any memory leaks during 42 School projects.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published