diff --git a/README.md b/README.md new file mode 100644 index 0000000..f55d63b --- /dev/null +++ b/README.md @@ -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" +``` diff --git a/examples/leak b/examples/leak new file mode 100755 index 0000000..6d230d1 Binary files /dev/null and b/examples/leak differ diff --git a/examples/leak.cpp b/examples/leak.cpp new file mode 100644 index 0000000..a7e593a --- /dev/null +++ b/examples/leak.cpp @@ -0,0 +1,17 @@ +#include +#include + +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; +}