Ignore:
Timestamp:
Nov 5, 2015, 4:41:37 PM (4 years ago)
Author:
nmedfort
Message:

Back up check in. Memory leaks should be fixed.

Location:
icGREP/icgrep-devel/icgrep/re
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/re/re_cc.h

    r4814 r4860  
    5050    friend CC * makeCC(const codepoint_t lo, const codepoint_t hi);
    5151    friend CC * makeCC(const CC * cc1, const CC * cc2);
    52     friend CC * makeCC(const std::initializer_list<interval_t> list);
    53     friend CC * makeCC(const std::vector<interval_t> & list);
     52    friend CC * makeCC(std::initializer_list<interval_t> list);
     53    friend CC * makeCC(std::vector<interval_t> && list);
    5454    friend CC * makeCC(UCD::UnicodeSet && set);
    5555    friend CC * subtractCC(const CC * a, const CC * b);
     
    8484    }
    8585
    86     template <typename itr>
    87     CC * initialize(itr begin, itr end);
     86    CC(std::initializer_list<interval_t>::iterator begin, std::initializer_list<interval_t>::iterator end)
     87    : RE(ClassTypeId::CC)
     88    , UCD::UnicodeSet(begin, end)
     89    {
     90
     91    }
     92
     93    CC(const std::vector<interval_t>::iterator begin, const std::vector<interval_t>::iterator end)
     94    : RE(ClassTypeId::CC)
     95    , UCD::UnicodeSet(begin, end)
     96    {
     97
     98    }
    8899
    89100};
     
    109120inline codepoint_t hi_codepoint(const CC::iterator i) {
    110121    return hi_codepoint(*i);
    111 }
    112 
    113 template<typename itr>
    114 CC * CC::initialize(itr begin, itr end) {
    115     for (auto i = begin; i != end; ++i) {
    116         insert_range(i->first, i->second);
    117     }
    118     return this;
    119122}
    120123
     
    143146}
    144147
    145 inline CC * makeCC(const std::initializer_list<interval_t> list) {
    146     return makeCC()->initialize(list.begin(), list.end());
     148inline CC * makeCC(std::initializer_list<interval_t> list) {
     149    return new CC(list.begin(), list.end());
    147150}
    148151
    149 inline CC * makeCC(const std::vector<interval_t> & list) {
    150     return makeCC()->initialize(list.begin(), list.end());
     152inline CC * makeCC(std::vector<interval_t> && list) {
     153    return new CC(list.begin(), list.end());
    151154}
    152155
     
    156159
    157160inline CC * subtractCC(const CC * a, const CC * b) {
    158     return makeCC(std::move(*a - *b));
     161    return new CC(std::move(*a - *b));
    159162}
    160163
    161164inline CC * intersectCC(const CC * a, const CC * b) {
    162     return makeCC(std::move(*a & *b));
     165    return new CC(std::move(*a & *b));
    163166}
    164167
  • icGREP/icgrep-devel/icgrep/re/re_parser.cpp

    r4852 r4860  
    531531    embedded = regular_expression_passes(encoding, embedded);
    532532
    533     pablo::PabloFunction * nameSearchFunction = re2pablo_compiler(encoding, embedded);
    534     llvm::Function * nameSearchIR = nullptr;
    535    
     533    pablo::PabloFunction * const nameSearchFunction = re2pablo_compiler(encoding, embedded);
    536534    pablo_function_passes(nameSearchFunction);
    537535    pablo::PabloCompiler pablo_compiler(VectorType::get(IntegerType::get(getGlobalContext(), 64), BLOCK_SIZE/64));
    538     try {
    539         nameSearchIR = pablo_compiler.compile(nameSearchFunction);
    540     }
    541     catch (std::runtime_error e) {
    542         releaseSlabAllocatorMemory();
    543         throw e;
    544     }
     536    llvm::Function * const nameSearchIR = pablo_compiler.compile(nameSearchFunction); // <- may throw error if parsing exception occurs.
    545537
    546538    llvm::ExecutionEngine * engine = JIT_to_ExecutionEngine(nameSearchIR);   
  • icGREP/icgrep-devel/icgrep/re/re_re.cpp

    r4510 r4860  
    33namespace re {
    44RE::Allocator RE::mAllocator;
    5 RE::VectorAllocator RE::mVectorAllocator;
    65}
  • icGREP/icgrep-devel/icgrep/re/re_re.h

    r4829 r4860  
    3939public:
    4040    using Allocator = SlabAllocator<u_int8_t>;
    41     using VectorAllocator = SlabAllocator<RE *>;
     41    using VectorAllocator = Allocator::rebind<RE *>::other;
    4242    enum class ClassTypeId : unsigned {
    4343        Alt
     
    7272
    7373    static Allocator mAllocator;
    74     static VectorAllocator mVectorAllocator;
    7574};
    7675
     
    8382    inline Vector(const ClassTypeId id)
    8483    : RE(id)
    85     , std::vector<RE*, RE::VectorAllocator>(RE::mVectorAllocator)
     84    , std::vector<RE*, RE::VectorAllocator>(reinterpret_cast<VectorAllocator &>(mAllocator))
    8685    {
    8786
     
    8988    inline Vector(const ClassTypeId id, const iterator begin, const iterator end)
    9089    : RE(id)
    91     , std::vector<RE*, RE::VectorAllocator>(begin, end, RE::mVectorAllocator) {
     90    , std::vector<RE*, RE::VectorAllocator>(begin, end, reinterpret_cast<VectorAllocator &>(mAllocator)) {
    9291
    9392    }
Note: See TracChangeset for help on using the changeset viewer.