rust: Fix segfault
Signed-off-by: gatecat <gatecat@ds0.me>
This commit is contained in:
parent
1bbcc5f2c4
commit
e12ab86c75
10
rust/rust.cc
10
rust/rust.cc
@ -104,7 +104,7 @@ extern "C" {
|
|||||||
*pips = new uint64_t[size];
|
*pips = new uint64_t[size];
|
||||||
auto idx = 0;
|
auto idx = 0;
|
||||||
for (auto pip : ctx->getPips()) {
|
for (auto pip : ctx->getPips()) {
|
||||||
*pips[idx] = wrap(pip);
|
(*pips)[idx] = wrap(pip);
|
||||||
idx++;
|
idx++;
|
||||||
}
|
}
|
||||||
// Yes, by never deleting pip_vec, we leak memory.
|
// Yes, by never deleting pip_vec, we leak memory.
|
||||||
@ -118,7 +118,7 @@ extern "C" {
|
|||||||
*wires = new uint64_t[size];
|
*wires = new uint64_t[size];
|
||||||
auto idx = 0;
|
auto idx = 0;
|
||||||
for (auto wire : ctx->getWires()) {
|
for (auto wire : ctx->getWires()) {
|
||||||
*wires[idx] = wrap(wire);
|
(*wires)[idx] = wrap(wire);
|
||||||
idx++;
|
idx++;
|
||||||
}
|
}
|
||||||
// Yes, by never deleting wires, we leak memory.
|
// Yes, by never deleting wires, we leak memory.
|
||||||
@ -142,8 +142,8 @@ extern "C" {
|
|||||||
*nets = new NetInfo*[size];
|
*nets = new NetInfo*[size];
|
||||||
auto idx = 0;
|
auto idx = 0;
|
||||||
for (auto& item : ctx->nets) {
|
for (auto& item : ctx->nets) {
|
||||||
*names[idx] = item.first.index;
|
(*names)[idx] = item.first.index;
|
||||||
*nets[idx] = item.second.get();
|
(*nets)[idx] = item.second.get();
|
||||||
idx++;
|
idx++;
|
||||||
}
|
}
|
||||||
// Yes, by never deleting `names` and `nets` we leak memory.
|
// Yes, by never deleting `names` and `nets` we leak memory.
|
||||||
@ -179,7 +179,7 @@ extern "C" {
|
|||||||
*users = new PortRef*[size];
|
*users = new PortRef*[size];
|
||||||
auto idx = 0;
|
auto idx = 0;
|
||||||
for (auto& item : net->users) {
|
for (auto& item : net->users) {
|
||||||
*users[idx] = &item;
|
(*users)[idx] = &item;
|
||||||
idx++;
|
idx++;
|
||||||
}
|
}
|
||||||
// Yes, by not freeing `users`, we leak memory.
|
// Yes, by not freeing `users`, we leak memory.
|
||||||
|
Loading…
Reference in New Issue
Block a user