[2/3] ctf-reader: Use smart pointers in create_read_context
Commit Message
* include/abg-ctf-reader.h (read_context_sptr): New typedef.
(create_read_context): Use smart pointer as return value.
* src/abg-ctf-reader.cc: Likewise.
* tools/abidiff.cc (main): Use read_context_sptr.
* tools/abilint.cc: Likewise.
---
include/abg-ctf-reader.h | 7 +++++--
src/abg-ctf-reader.cc | 5 +++--
tools/abidiff.cc | 18 ++++++++++--------
tools/abilint.cc | 8 ++++----
4 files changed, 22 insertions(+), 16 deletions(-)
@@ -25,8 +25,11 @@ namespace ctf_reader
{
class read_context;
-read_context *create_read_context(const std::string& elf_path,
- ir::environment *env);
+typedef shared_ptr<read_context> read_context_sptr;
+
+read_context_sptr
+create_read_context(const std::string& elf_path,
+ ir::environment *env);
corpus_sptr read_corpus(read_context *ctxt,
elf_reader::status& status);
@@ -1059,11 +1059,12 @@ slurp_elf_info(read_context *ctxt, corpus_sptr corp)
/// @param elf_path the patch of some ELF file.
/// @param env a libabigail IR environment.
-read_context *
+read_context_sptr
create_read_context(const std::string& elf_path,
ir::environment *env)
{
- return new read_context(elf_path, env);
+ read_context_sptr result(new read_context(elf_path, env));
+ return result;
}
/// Read the CTF information from some source described by a given
@@ -1169,12 +1169,13 @@ main(int argc, char* argv[])
#ifdef WITH_CTF
if (opts.use_ctf)
{
- abigail::ctf_reader::read_context *ctxt
- = abigail::ctf_reader::create_read_context (opts.file1,
- env.get());
+ abigail::ctf_reader::read_context_sptr ctxt
+ = abigail::ctf_reader::create_read_context(opts.file1,
+ env.get());
assert (ctxt);
- c1 = abigail::ctf_reader::read_corpus (ctxt, c1_status);
+ c1 = abigail::ctf_reader::read_corpus(ctxt.get(),
+ c1_status);
}
else
#endif
@@ -1252,12 +1253,13 @@ main(int argc, char* argv[])
#ifdef WITH_CTF
if (opts.use_ctf)
{
- abigail::ctf_reader::read_context *ctxt
- = abigail::ctf_reader::create_read_context (opts.file2,
- env.get());
+ abigail::ctf_reader::read_context_sptr ctxt
+ = abigail::ctf_reader::create_read_context(opts.file2,
+ env.get());
assert (ctxt);
- c2 = abigail::ctf_reader::read_corpus (ctxt, c2_status);
+ c2 = abigail::ctf_reader::read_corpus (ctxt.get(),
+ c2_status);
}
else
#endif
@@ -370,12 +370,12 @@ main(int argc, char* argv[])
#ifdef WITH_CTF
if (opts.use_ctf)
{
- abigail::ctf_reader::read_context *ctxt
- = abigail::ctf_reader::create_read_context (opts.file_path,
- env.get());
+ abigail::ctf_reader::read_context_sptr ctxt
+ = abigail::ctf_reader::create_read_context(opts.file_path,
+ env.get());
assert (ctxt);
- corp = abigail::ctf_reader::read_corpus (ctxt, s);
+ corp = abigail::ctf_reader::read_corpus (ctxt.get(), s);
}
else
#endif