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

Back up check in. Memory leaks should be fixed.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/pablo/symbol_generator.cpp

    r4510 r4860  
    1111namespace pablo {
    1212
    13 SymbolGenerator::SymbolGenerator()
    14 : mPrefixMap()
    15 {
    16 
    17 }
    18 
    1913String * SymbolGenerator::get(const std::string name, const bool generated) {
     14    if (name.length() == 0) {
     15        throw std::runtime_error("symbol name cannot be 0-length");
     16    }
    2017    auto f = mStringMap.find(name);
    21     String * result;
     18    String * result = nullptr;
    2219    if (f == mStringMap.end()) {
    2320        result = new String(name, generated);
     21        assert (result);
    2422        mStringMap.insert(std::make_pair(std::move(name), result));
    2523    }
     
    3735        assert (result->value() == value);
    3836        mIntegerMap.insert(std::make_pair(value, result));
    39     }
    40     else {
     37    } else {
    4138        result = f->second;
    4239    }
     
    5047        mPrefixMap.insert(std::make_pair(prefix, 1));
    5148        return get(prefix, generated);
    52     }
    53     else {
     49    } else {
    5450        count = f->second++;
    5551        return get(prefix + std::to_string(count), generated);
     
    5753}
    5854
    59 SymbolGenerator::~SymbolGenerator() {
    60 
    6155}
    62 
    63 }
Note: See TracChangeset for help on using the changeset viewer.