Skip to content

Commit

Permalink
replace malloc with new (rust-lang#302)
Browse files Browse the repository at this point in the history
  • Loading branch information
tgymnich committed Aug 17, 2021
1 parent 3cb34f1 commit 820a0eb
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions enzyme/Enzyme/CApi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ CConcreteType ewrap(const ConcreteType &CT) {
IntList ewrap(const std::vector<int> &offsets) {
IntList IL;
IL.size = offsets.size();
IL.data = (int64_t *)malloc(IL.size * sizeof(*IL.data));
IL.data = new int64_t[IL.size];
for (size_t i = 0; i < offsets.size(); i++) {
IL.data[i] = offsets[i];
}
Expand Down Expand Up @@ -195,7 +195,7 @@ EnzymeTypeAnalysisRef CreateTypeAnalysis(char *TripleStr,
for (size_t i = 0; i < argTrees.size(); ++i) {
cargs[i] = (CTypeTreeRef)(&(argTrees[i]));
kvs[i].size = knownValues[i].size();
kvs[i].data = (int64_t *)malloc(kvs[i].size * sizeof(*kvs[i].data));
kvs[i].data = new int64_t[kvs[i].size];
size_t j = 0;
for (auto val : knownValues[i]) {
kvs[i].data[j] = val;
Expand All @@ -206,7 +206,7 @@ EnzymeTypeAnalysisRef CreateTypeAnalysis(char *TripleStr,
rule(direction, creturnTree, cargs, kvs, argTrees.size(), wrap(call));
delete[] cargs;
for (size_t i = 0; i < argTrees.size(); ++i) {
free(kvs[i].data);
delete[] kvs[i].data;
}
delete[] kvs;
return result;
Expand Down

0 comments on commit 820a0eb

Please sign in to comment.