https://github.com/slayers-git/leakchk
Simple leak checker and allocation tracker for C/C++
https://github.com/slayers-git/leakchk
Last synced: about 1 year ago
JSON representation
Simple leak checker and allocation tracker for C/C++
- Host: GitHub
- URL: https://github.com/slayers-git/leakchk
- Owner: slayers-git
- License: lgpl-2.1
- Created: 2022-06-12T07:16:09.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2022-06-12T07:23:07.000Z (almost 4 years ago)
- Last Synced: 2025-02-12T01:41:25.201Z (about 1 year ago)
- Language: C
- Size: 13.7 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# LeakCHK
LeakCHK is a simple, thread-safe leak checker that replaces the regular `stdlib.h` memory allocation functions with those, that track the number of allocations and the location where they happened.
## Usage
### Code
```c
#include
int main (void) {
if (lc_init () != 0) {
return -1;
}
void *p = lc_malloc (23);
lc_deinit ();
return 0;
}
```
### Output
```bash
$ gcc example.c -lleakchk
$ ./a.out
LEAKCHK: 1 tracked allocations have not been freed:
LC_BLOCK @0xFFFFF67923A9:
size: 23, allocated in example.c:8 (function main)
```
## Building
To build the library on a \*NIX system clone the repository and it's submodules:
```bash
$ git clone https://github.com/slayers-git/leakchk.git
$ git submodule update --init
```
Then execute:
```bash
$ mkdir -p build && cd build
$ cmake ../ && make
```