Skip to content

Commit

Permalink
leaks
Browse files Browse the repository at this point in the history
  • Loading branch information
jjcherry56 committed Feb 7, 2021
1 parent e3d60f0 commit 6359bd6
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 16 deletions.
9 changes: 7 additions & 2 deletions liberty/LibertyParser.cc
Original file line number Diff line number Diff line change
Expand Up @@ -522,8 +522,13 @@ libertyIncludeBegin(const char *filename)
liberty_filename = filename;
liberty_line = 1;
}
else
libertyParseError("cannot open include file %s.", filename);
else {
// Copy the filename to the stack so it is deleted when
// libertyParseError throws an error.
string filename1(filename);
stringDelete(filename);
libertyParseError("cannot open include file %s.", filename1.c_str());
}
return stream;
}

Expand Down
15 changes: 12 additions & 3 deletions liberty/LibertyReader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -600,6 +600,7 @@ LibertyReader::endLibraryAttrs(LibertyGroup *group)
else
libWarn(31, group, "default_wire_load %s not found.", default_wireload_);
stringDelete(default_wireload_);
default_wireload_ = nullptr;
}

if (default_wireload_selection_) {
Expand All @@ -611,6 +612,7 @@ LibertyReader::endLibraryAttrs(LibertyGroup *group)
libWarn(32, group, "default_wire_selection %s not found.",
default_wireload_selection_);
stringDelete(default_wireload_selection_);
default_wireload_selection_ = nullptr;
}

if (default_operating_condition_) {
Expand All @@ -622,6 +624,7 @@ LibertyReader::endLibraryAttrs(LibertyGroup *group)
libWarn(60, group, "default_operating_condition %s not found.",
default_operating_condition_);
stringDelete(default_operating_condition_);
default_operating_condition_ = nullptr;
}

bool missing_threshold = false;
Expand Down Expand Up @@ -1074,8 +1077,10 @@ LibertyReader::visitDefaultWireLoad(LibertyAttr *attr)
{
if (library_) {
const char *value = getAttrString(attr);
if (value)
if (value) {
stringDelete(default_wireload_);
default_wireload_ = stringCopy(value);
}
}
}

Expand All @@ -1100,8 +1105,10 @@ LibertyReader::visitDefaultWireLoadSelection(LibertyAttr *attr)
{
if (library_) {
const char *value = getAttrString(attr);
if (value)
if (value) {
stringDelete(default_wireload_selection_);
default_wireload_selection_ = stringCopy(value);
}
}
}

Expand All @@ -1110,8 +1117,10 @@ LibertyReader::visitDefaultOperatingConditions(LibertyAttr *attr)
{
if (library_) {
const char *value = getAttrString(attr);
if (value)
if (value) {
stringDelete(default_operating_condition_);
default_operating_condition_ = stringCopy(value);
}
}
}

Expand Down
1 change: 1 addition & 0 deletions verilog/Verilog.i
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ write_verilog_cmd(const char *filename,
Sta *sta = Sta::sta();
Network *network = sta->network();
writeVerilog(filename, sort, include_pwr_gnd, remove_cells, network);
delete remove_cells;
}

%} // inline
17 changes: 6 additions & 11 deletions verilog/VerilogReader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,10 @@ class VerilogError
const char *msg,
bool warn);
~VerilogError();
void report(Report *report);
const char *msg() const { return msg_; }
const char *filename() const { return filename_; }
int id() const { return id_; }
int line() const { return line_; }
bool warn() const { return warn_; }

private:
Expand Down Expand Up @@ -114,15 +117,6 @@ VerilogError::~VerilogError()
stringDelete(msg_);
}

void
VerilogError::report(Report *report)
{
if (warn_)
report->fileWarn(id_, filename_, line_, "%s", msg_);
else
report->fileError(id_, filename_, line_, "%s", msg_);
}

class VerilogErrorCmp
{
public:
Expand Down Expand Up @@ -2224,7 +2218,8 @@ VerilogReader::reportLinkErrors(Report *report)
VerilogErrorSeq::Iterator error_iter(link_errors_);
while (error_iter.hasNext()) {
VerilogError *error = error_iter.next();
error->report(report);
// Report as warnings to avoid throwing.
report->fileWarn(error->id(), error->filename(), error->line(), "%s", error->msg());
errors |= !error->warn();
delete error;
}
Expand Down

0 comments on commit 6359bd6

Please sign in to comment.