added examples
This commit is contained in:
parent
5b8692cee7
commit
51e80b0e03
3 changed files with 40 additions and 0 deletions
23
README.md
Normal file
23
README.md
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
# Docker container for valgrind
|
||||||
|
|
||||||
|
## Использование
|
||||||
|
|
||||||
|
Запуск контейнера:
|
||||||
|
`docker run -it --rm -v $PWD/path/to/my/files:/valgrind shahfil/valgrind:latest`
|
||||||
|
|
||||||
|
Запуск проверки в обычном режиме:
|
||||||
|
`valgrind ./your_executable`
|
||||||
|
|
||||||
|
### Пример использования
|
||||||
|
```
|
||||||
|
docker run -it --rm -v $PWD/examples:/valgrind shahfil/valgrind:latest
|
||||||
|
|
||||||
|
make
|
||||||
|
valgrind ./leak
|
||||||
|
valgrind --leak-check=full -s ./leak
|
||||||
|
exit
|
||||||
|
```
|
||||||
|
или то же самое одной командой:
|
||||||
|
```
|
||||||
|
docker run -it --rm -v $PWD/examples:/valgrind shahfil/valgrind:latest /bin/bash -c "make && valgrind ./leak"
|
||||||
|
```
|
BIN
examples/leak
Executable file
BIN
examples/leak
Executable file
Binary file not shown.
17
examples/leak.cpp
Normal file
17
examples/leak.cpp
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
#include <cstdlib>
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
int
|
||||||
|
main (void)
|
||||||
|
{
|
||||||
|
size_t *n = 0;
|
||||||
|
n = (size_t *) malloc (sizeof (size_t) * 3);
|
||||||
|
|
||||||
|
for (size_t idx = 0; idx < 3; idx++)
|
||||||
|
{
|
||||||
|
*(n + idx) = idx;
|
||||||
|
std::cout << *(n + idx) << std::endl;
|
||||||
|
}
|
||||||
|
// free ((void *) n);
|
||||||
|
return 0;
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue