mirror of
git://sourceware.org/git/libabigail.git
synced 2024-12-25 19:22:07 +00:00
b71e5c6f22
The suppression engine was not creating the shared pointer to regex_t in the proper way that would correctly free the memory allocated by the glibc's regcomp function. This patch fixes that. * include/abg-sptr-utils.h (build_sptr<T>): Declare an overload that allocates a T* and wraps it into a shared_ptr<T>. (build_sptr<regex_t>): Declare a specialization for regex_t. * src/abg-corpus.cc (build_sptr<regex_t>()): Define the specialization here. * src/abg-suppression.ccp (suppression_base::priv::{get_file_[not]_name_regex, get_soname_[not]_regex}): Use the new build_sptr<regex_t>(). (type_suppression::priv::{get_type_name_regex, get_source_location_to_keep_regex}): Likewise. (function_suppression::parameter_spec::priv::get_type_name_regex): Likewise. (function_suppression::priv::{get_name_regex, get_return_type_regex, get_symbol_name_regex, get_symbol_version_regex}): Likewise. (variable_suppression::priv::{get_name_regex, get_symbol_name_regex, get_symbol_version_regex, get_type_name_regex}): Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
107 lines
2.9 KiB
C++
107 lines
2.9 KiB
C++
// -*- mode: C++ -*-
|
|
//
|
|
// Copyright (C) 2013-2015 Red Hat, Inc.
|
|
//
|
|
// This file is part of the GNU Application Binary Interface Generic
|
|
// Analysis and Instrumentation Library (libabigail). This library is
|
|
// free software; you can redistribute it and/or modify it under the
|
|
// terms of the GNU Lesser General Public License as published by the
|
|
// Free Software Foundation; either version 3, or (at your option) any
|
|
// later version.
|
|
|
|
// This library is distributed in the hope that it will be useful, but
|
|
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
// General Lesser Public License for more details.
|
|
|
|
// You should have received a copy of the GNU Lesser General Public
|
|
// License along with this program; see the file COPYING-LGPLV3. If
|
|
// not, see <http://www.gnu.org/licenses/>.
|
|
|
|
/// @file
|
|
///
|
|
/// Utilities to ease the wrapping of C types into std::tr1::shared_ptr
|
|
|
|
#ifndef __ABG_SPTR_UTILS_H__
|
|
#define __ABG_SPTR_UTILS_H__
|
|
|
|
#include <tr1/memory>
|
|
#include <regex.h>
|
|
#include <libxml/xmlreader.h>
|
|
|
|
namespace abigail
|
|
{
|
|
|
|
/// Namespace for the utilities to wrap C types into std::tr1::shared_ptr.
|
|
namespace sptr_utils
|
|
{
|
|
|
|
using std::tr1::shared_ptr;
|
|
|
|
/// This is to be specialized for the diverse C types that needs
|
|
/// wrapping in shared_ptr.
|
|
///
|
|
/// @tparam T the type of the C type to wrap in a shared_ptr.
|
|
///
|
|
/// @param p a pointer to wrap in a shared_ptr.
|
|
///
|
|
/// @return then newly created shared_ptr<T>
|
|
template<class T>
|
|
shared_ptr<T>
|
|
build_sptr(T* p);
|
|
|
|
/// This is to be specialized for the diverse C types that needs
|
|
/// wrapping in shared_ptr.
|
|
///
|
|
/// This variant creates a pointer to T and wraps it into a
|
|
/// shared_ptr<T>.
|
|
///
|
|
/// @tparam T the type of the C type to wrap in a shared_ptr.
|
|
///
|
|
/// @return then newly created shared_ptr<T>
|
|
template<class T>
|
|
shared_ptr<T>
|
|
build_sptr();
|
|
|
|
/// A convenience typedef for a shared pointer of xmlTextReader.
|
|
typedef shared_ptr<xmlTextReader> reader_sptr;
|
|
|
|
/// Specialization of sptr_utils::build_sptr for xmlTextReader
|
|
template<>
|
|
reader_sptr
|
|
build_sptr<xmlTextReader>(xmlTextReader *p);
|
|
|
|
/// A convenience typedef for a shared pointer of xmlChar.
|
|
typedef shared_ptr<xmlChar> xml_char_sptr;
|
|
|
|
/// Specialization of build_str for xmlChar.
|
|
template<>
|
|
xml_char_sptr build_sptr<xmlChar>(xmlChar *p);
|
|
|
|
/// A convenience typedef for a shared pointer of regex_t.
|
|
typedef shared_ptr<regex_t> regex_t_sptr;
|
|
|
|
/// Specialization of sptr_utils::build_sptr for regex_t.
|
|
template<>
|
|
regex_t_sptr
|
|
build_sptr<regex_t>(regex_t *p);
|
|
|
|
/// Specialization of sptr_utils::build_sptr for regex_t.
|
|
template<>
|
|
regex_t_sptr
|
|
build_sptr<regex_t>();
|
|
|
|
/// A deleter for shared pointers that ... doesn't delete the object
|
|
/// managed by the shared pointer.
|
|
struct noop_deleter
|
|
{
|
|
template<typename T>
|
|
void
|
|
operator()(const T*)
|
|
{}
|
|
};
|
|
}// end namespace sptr_utils
|
|
}// end namespace abigail
|
|
|
|
#endif //__ABG_SPTR_UTILS_H__
|