mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Valgrind: fix "definitely lost" memory in test - test-lots
==67054== 320 bytes in 32 blocks are definitely lost in loss record 2,213 of 2,238 ==67054== at 0x4848A13: calloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so) ==67054== by 0x503C550: g_malloc0 (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.7600.1) ==67054== by 0x118AD8: get_random_transaction_with_currency (test-engine-stuff.cpp:1395) ==67054== by 0x119897: add_random_transactions_to_book (test-engine-stuff.cpp:1848) ==67054== by 0x115FE8: run_test() (test-lots.cpp:99) ==67054== by 0x1160BF: main (test-lots.cpp:135) ==67054==
This commit is contained in:
@@ -52,6 +52,9 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include <string>
|
||||
|
||||
#include <qof.h>
|
||||
|
||||
#include "Account.h"
|
||||
@@ -1376,8 +1379,6 @@ get_random_transaction_with_currency(QofBook *book,
|
||||
{
|
||||
Transaction* trans;
|
||||
KvpFrame *f;
|
||||
gint num;
|
||||
gchar *numstr;
|
||||
|
||||
if (!account_list)
|
||||
{
|
||||
@@ -1392,8 +1393,6 @@ get_random_transaction_with_currency(QofBook *book,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
numstr = g_new0(gchar, 10);
|
||||
|
||||
trans = xaccMallocTransaction(book);
|
||||
|
||||
xaccTransBeginEdit(trans);
|
||||
@@ -1402,9 +1401,10 @@ get_random_transaction_with_currency(QofBook *book,
|
||||
currency ? currency :
|
||||
get_random_commodity (book));
|
||||
|
||||
num = get_random_int_in_range (1, max_trans_num);
|
||||
g_snprintf(numstr, 10, "%d", num);
|
||||
xaccTransSetNum(trans, numstr);
|
||||
gint num = get_random_int_in_range (1, max_trans_num);
|
||||
auto numstr = std::to_string(num);
|
||||
xaccTransSetNum(trans, numstr.c_str());
|
||||
|
||||
set_tran_random_string_from_array(trans, xaccTransSetDescription,
|
||||
sane_descriptions);
|
||||
trn_add_ran_time(trans, xaccTransSetDatePostedSecs);
|
||||
|
||||
Reference in New Issue
Block a user