Split shared free_bytes into common source and fix ffi includes.

This commit is contained in:
Alejandro Cabeza Romero 2026-04-10 20:04:03 +02:00
parent dfe86c6282
commit 2e1dd99ac5
No known key found for this signature in database
GPG Key ID: DA3D14AE478030FD
2 changed files with 17 additions and 15 deletions

13
src/common.cpp Normal file
View File

@ -0,0 +1,13 @@
#include "types.hpp"
#include <cstdlib>
extern "C" void free_bytes(Bytes* bytes) {
if (bytes == nullptr) {
return;
}
free(bytes->data);
bytes->data = nullptr;
bytes->size = 0;
}

View File

@ -1,15 +1,14 @@
#include "ffi.hpp."
#include "ffi.hpp"
#include <string>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <nlohmann/json.hpp>
#include "calcwit.hpp."
#include "circom.hpp."
#include "fr.hpp."
#include "calcwit.hpp"
#include "circom.hpp"
#include "fr.hpp"
using json = nlohmann::json;
@ -132,13 +131,3 @@ extern "C" Status generate_witness(const WitnessInput* input, Bytes* output) {
return generate_witness_impl(input, output);
});
}
extern "C" void free_bytes(Bytes* bytes) {
if (bytes == nullptr) {
return;
}
free(bytes->data);
bytes->data = nullptr;
bytes->size = 0;
}