diff --git a/src/fcmp/fcmp_rust/fcmp++.h b/src/fcmp/fcmp_rust/fcmp++.h index ccfa2b90d..2648d3c7f 100644 --- a/src/fcmp/fcmp_rust/fcmp++.h +++ b/src/fcmp/fcmp_rust/fcmp++.h @@ -72,9 +72,8 @@ struct SelenePoint { // ----- End deps C bindings ----- -template struct CResult { - T* value; + void* value; void* err; }; @@ -111,17 +110,12 @@ HeliosScalar helios_zero_scalar(); SeleneScalar selene_zero_scalar(); -CResult hash_grow_helios(HeliosPoint existing_hash, +CResult hash_grow_helios(HeliosPoint existing_hash, uintptr_t offset, HeliosScalar existing_child_at_offset, HeliosScalarSlice new_children); -CResult hash_trim_helios(HeliosPoint existing_hash, - uintptr_t offset, - HeliosScalarSlice children, - HeliosScalar child_to_grow_back); - -CResult hash_grow_selene(SelenePoint existing_hash, +CResult hash_grow_selene(SelenePoint existing_hash, uintptr_t offset, SeleneScalar existing_child_at_offset, SeleneScalarSlice new_children); diff --git a/src/fcmp/tower_cycle.cpp b/src/fcmp/tower_cycle.cpp index 2bf6f7459..5679a310d 100644 --- a/src/fcmp/tower_cycle.cpp +++ b/src/fcmp/tower_cycle.cpp @@ -51,14 +51,18 @@ Helios::Point Helios::hash_grow( const Helios::Scalar &existing_child_at_offset, const Helios::Chunk &new_children) const { - fcmp_rust::CResult result = fcmp_rust::hash_grow_helios( + auto result = fcmp_rust::hash_grow_helios( existing_hash, offset, existing_child_at_offset, new_children); - if (result.err != nullptr) { - throw std::runtime_error("failed to hash grow"); + + if (result.err != nullptr) + { + free(result.err); + throw std::runtime_error("failed to hash grow"); } + typename Helios::Point res; memcpy(&res, result.value, sizeof(typename Selene::Point)); free(result.value); @@ -88,14 +92,18 @@ Selene::Point Selene::hash_grow( const Selene::Scalar &existing_child_at_offset, const Selene::Chunk &new_children) const { - fcmp_rust::CResult result = fcmp_rust::hash_grow_selene( + auto result = fcmp_rust::hash_grow_selene( existing_hash, offset, existing_child_at_offset, new_children); - if (result.err != nullptr) { - throw std::runtime_error("failed to hash grow"); + + if (result.err != nullptr) + { + free(result.err); + throw std::runtime_error("failed to hash grow"); } + typename Selene::Point res; memcpy(&res, result.value, sizeof(typename Selene::Point)); free(result.value);