NezukoCS is a lightweight Garbage Collector designed for C programmers to simplify memory management. It provides a set of functions to allocate and deallocate memory efficiently and automatically, ensuring that memory is properly managed and helping you avoid any memory leaks.
With Nezuko Cleaning Services in the house, you can focus on writing clean, reliable code without worrying about memory management complexities.
- Allocation and deallocation of memory.
- Cleaning up all allocated memory automatically.
NezukoCS provides three main functions for memory management:
-
To allocate memory, use the allocate function.
It takes an integer as a size for the memory to allocate and returns a pointer to the allocated memory.int* ptr = allocate(sizeof(int));
-
To deallocate memory, use the deallocate function. It takes a pointer to the memory to deallocate.
deallocate(ptr);
-
To clean up all allocated memory, just call nezuko and let her do the rest.
Nezuko will later update you on the cleaning results at the end of the execution.
nezuko();
-
#include <nezukoCS.h> int main() { // Allocate memory int* ptr1 = allocate(sizeof(int)); double* ptr2 = allocate(sizeof(double) * 10); char* ptr3 = allocate(20); // Deallocate memory deallocate(ptr1); deallocate(ptr2); deallocate(ptr3); return nezuko(); // call Nezuko }
Output
It looks like there's nothing left for Nezuko to clean! Good job.
-
#include <nezukoCS.h> int main() { // Allocate memory int* ptr1 = allocate(sizeof(int)); double* ptr2 = allocate(sizeof(double) * 10); char* ptr3 = allocate(20); // Deallocate ptr1 deallocate(ptr1); deallocate(ptr2); // forgot to deallocate ptr3 return nezuko(); // call Nezuko }
Output
Nezuko cleaned 20 bytes of allocated memory.
-
#include <nezukoCS.h> int main() { // Allocate memory int* ptr1 = allocate(sizeof(int)); double* ptr2 = allocate(sizeof(double) * 10); char* ptr3 = allocate(20); // Didn't deallocate any memory return nezuko(); // call Nezuko 😌💗 }
Output
Nezuko cleaned 104 bytes of allocated memory.
-
Download the package file:
Download the raw code file from Github or from the link below:
Link: Download NezukoCS from here
-
Paste the downloaded file in the compiler's include directory:
LLVM Clang Compiler:
C:\LLVM\lib\clang\17\include\GNU GCC Compiler:
C:\MinGW\include\Note: The paths may slightly differ so try to look up your own.
-
Include NezukoCS in your project:
#include <nezukoCS.h>
Shout out to Ayres for all his inspiration, love, and support. 🤍
