Skip to content

Resource #233

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: resource
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions homework/resourceD/resourceD.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include <iostream>
#include <stdexcept>
#include <memory>

using namespace std;

Expand All @@ -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<Resource> rsc{new Resource()};
auto rsc = std::make_unique<Resource>();
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;
}

15 changes: 15 additions & 0 deletions homework/resourceD/valgrind-output.txt
Original file line number Diff line number Diff line change
@@ -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)
Loading