https://github.com/mohammedhrima/garbage_collector
protect your C programs from memory leak and double free
https://github.com/mohammedhrima/garbage_collector
malloc memory-allocation memory-leak memory-management
Last synced: about 1 month ago
JSON representation
protect your C programs from memory leak and double free
- Host: GitHub
- URL: https://github.com/mohammedhrima/garbage_collector
- Owner: mohammedhrima
- Created: 2023-01-13T18:21:41.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2024-03-31T01:00:16.000Z (about 1 year ago)
- Last Synced: 2025-03-29T15:04:20.419Z (2 months ago)
- Topics: malloc, memory-allocation, memory-leak, memory-management
- Language: C
- Homepage:
- Size: 78.1 KB
- Stars: 9
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## Usage :
```c
#include "header.h"void *ptr0 = allocate(1000);
int *ptr1 = allocate(2000);
free_address(ptr1);
char **ptr2 = allocate(5000);
char ***ptr3 = allocate(300);
free_memory();
```## Running Tests
```bash
git clone https://github.com/mohammedhrima/Garbage_collector.git
```
```bash
gcc memory.c your_file.c #don't forget to include header.h
```## Important : (what you need to know)
```
- void * , char**, int*** ..., are pointers that holds addresses
- Those pointers have the same size
- size of pointer depends on computer architecture !!!
- in 32-bit CPU size of pointer is 4 bytes
- in 64-bit CPU size of pointer is 8 bytes
...
```