patch memory leaks using analyzer

This commit is contained in:
woodser
2023-08-24 16:36:51 -04:00
parent 93cd0f47cd
commit 7d97007519
6 changed files with 163 additions and 38 deletions
+10 -1
View File
@@ -2,6 +2,7 @@
#include <iostream>
#include "wallet2.h"
#include "wallet/monero_wallet_full.h"
#include "utils/monero_utils.h"
using namespace std;
@@ -52,23 +53,27 @@ int main(int argc, const char* argv[]) {
// query a transaction by hash
monero_tx_query tx_query;
tx_query.m_hash = "314a0f1375db31cea4dac4e0a51514a6282b43792269b3660166d4d2b46437ca";
shared_ptr<monero_tx_wallet> tx = wallet_restored->get_txs(tx_query)[0];
vector<shared_ptr<monero_tx_wallet>> txs = wallet_restored->get_txs(tx_query);
shared_ptr<monero_tx_wallet> tx = txs[0];
for (const shared_ptr<monero_transfer> transfer : tx->get_transfers()) {
bool is_incoming = transfer->is_incoming().get();
uint64_t in_amount = transfer->m_amount.get();
int account_index = transfer->m_account_index.get();
}
monero_utils::free(txs);
// query incoming transfers to account 1
monero_transfer_query transfer_query;
transfer_query.m_is_incoming = true;
transfer_query.m_account_index = 1;
vector<shared_ptr<monero_transfer>> transfers = wallet_restored->get_transfers(transfer_query);
monero_utils::free(transfers);
// query unspent outputs
monero_output_query output_query;
output_query.m_is_spent = false;
vector<shared_ptr<monero_output_wallet>> outputs = wallet_restored->get_outputs(output_query);
monero_utils::free(outputs);
// create and sync a new wallet with a random seed
wallet_config = monero_wallet_config();
@@ -114,6 +119,7 @@ int main(int argc, const char* argv[]) {
tx_config.m_relay = true;
shared_ptr<monero_tx_wallet> sent_tx = wallet_restored->create_tx(tx_config);
bool in_pool = sent_tx->m_in_tx_pool.get(); // true
monero_utils::free(sent_tx);
// mine with 7 threads to push the network along
int num_threads = 7;
@@ -144,6 +150,7 @@ int main(int argc, const char* argv[]) {
shared_ptr<monero_tx_wallet> created_tx = wallet_restored->create_tx(tx_config);
uint64_t fee = created_tx->m_fee.get(); // "Are you sure you want to send ...?"
wallet_restored->relay_tx(*created_tx); // recipient receives notification within 5 seconds
monero_utils::free(created_tx);
// the recipient wallet will be notified
if (FUNDS_RECEIVED) cout << "Sample code completed successfully" << endl;
@@ -152,4 +159,6 @@ int main(int argc, const char* argv[]) {
// save and close the wallets
wallet_restored->close(true);
wallet_random->close(true);
delete wallet_restored;
delete wallet_random;
}