mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Valgrind: fix "definitely lost" memory from get_random_string() - test-employee
==88366== 8 bytes in 1 blocks are definitely lost in loss record 11 of 474 ==88366== at 0x4848A13: calloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so) ==88366== by 0x503C550: g_malloc0 (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.7600.1) ==88366== by 0x10B7E9: get_random_string_without (test-stuff.c:312) ==88366== by 0x10B866: get_random_string (test-stuff.c:333) ==88366== by 0x10AB64: test_string_fcn (test-employee.c:140) ==88366== by 0x10A7C1: test_employee (test-employee.c:87) ==88366== by 0x10AF6B: main (test-employee.c:246) + 4 more
This commit is contained in:
@@ -117,15 +117,14 @@ test_employee (void)
|
|||||||
g_list_free (list);
|
g_list_free (list);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
const char *str = get_random_string();
|
char *str = get_random_string();
|
||||||
const char *res;
|
|
||||||
GncAddress *addr;
|
|
||||||
|
|
||||||
addr = gncEmployeeGetAddr (employee);
|
GncAddress *addr = gncEmployeeGetAddr (employee);
|
||||||
gncAddressSetName (addr, str);
|
gncAddressSetName (addr, str);
|
||||||
res = qof_object_printable (GNC_ID_EMPLOYEE, employee);
|
const char *res = qof_object_printable (GNC_ID_EMPLOYEE, employee);
|
||||||
do_test (res != NULL, "Printable NULL?");
|
do_test (res != NULL, "Printable NULL?");
|
||||||
do_test (g_strcmp0 (str, res) == 0, "Printable equals");
|
do_test (g_strcmp0 (str, res) == 0, "Printable equals");
|
||||||
|
g_free (str);
|
||||||
}
|
}
|
||||||
|
|
||||||
qof_book_destroy (book);
|
qof_book_destroy (book);
|
||||||
@@ -137,7 +136,7 @@ test_string_fcn (QofBook *book, const char *message,
|
|||||||
const char * (*get)(const GncEmployee *))
|
const char * (*get)(const GncEmployee *))
|
||||||
{
|
{
|
||||||
GncEmployee *employee = gncEmployeeCreate (book);
|
GncEmployee *employee = gncEmployeeCreate (book);
|
||||||
char const *str = get_random_string ();
|
char *str = get_random_string ();
|
||||||
|
|
||||||
do_test (!gncEmployeeIsDirty (employee), "test if start dirty");
|
do_test (!gncEmployeeIsDirty (employee), "test if start dirty");
|
||||||
gncEmployeeBeginEdit (employee);
|
gncEmployeeBeginEdit (employee);
|
||||||
@@ -152,6 +151,7 @@ test_string_fcn (QofBook *book, const char *message,
|
|||||||
*/
|
*/
|
||||||
// do_test (!gncEmployeeIsDirty (employee), "test dirty after commit");
|
// do_test (!gncEmployeeIsDirty (employee), "test dirty after commit");
|
||||||
do_test (g_strcmp0 (get (employee), str) == 0, message);
|
do_test (g_strcmp0 (get (employee), str) == 0, message);
|
||||||
|
g_free (str);
|
||||||
gncEmployeeSetActive (employee, FALSE);
|
gncEmployeeSetActive (employee, FALSE);
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user