diff --git a/homework/resourceD/resourceD.cpp b/homework/resourceD/resourceD.cpp index 6de14868..3beb48b5 100644 --- a/homework/resourceD/resourceD.cpp +++ b/homework/resourceD/resourceD.cpp @@ -1,5 +1,6 @@ #include #include +#include using namespace std; @@ -24,17 +25,20 @@ int main(int argc, char* argv[]) exit(-1); } const char* N = argv[1]; - Resource* rsc = nullptr; + // Resource* rsc = nullptr; + // std::unique_ptr rsc{new Resource()}; + auto rsc = std::make_unique(); try { - rsc = new Resource(); + // rsc = new Resource(); rsc->use(N); - delete rsc; + // delete rsc; // Not reached statement when exception throw } catch (logic_error & e) { cout << e.what() << endl; } + // delete rsc; return 0; } diff --git a/homework/resourceD/valgrind-output.txt b/homework/resourceD/valgrind-output.txt index e69de29b..9e290231 100644 --- a/homework/resourceD/valgrind-output.txt +++ b/homework/resourceD/valgrind-output.txt @@ -0,0 +1,15 @@ +==11870== Memcheck, a memory error detector +==11870== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al. +==11870== Using Valgrind-3.18.1 and LibVEX; rerun with -h for copyright info +==11870== Command: ./resourceD d +==11870== +Using resource. Passed d +Passed d. d is prohibited. +==11870== +==11870== HEAP SUMMARY: +==11870== in use at exit: 0 bytes in 0 blocks +==11870== total heap usage: 5 allocs, 5 frees, 76,996 bytes allocated +==11870== +==11870== All heap blocks were freed -- no leaks are possible +==11870== +==11870== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)