res = g_bookmark_file_load_from_file (bookmark, filename, &error);
if (error && g_test_verbose ())
- {
- g_print ("Load error: %s\n", error->message);
- g_error_free (error);
- }
+ g_print ("Load error: %s\n", error->message);
+ g_clear_error (&error);
return res;
}
g_assert_cmpint (value_create_count, ==, 2);
g_assert_cmpint (value_destroy_count, ==, 1);
+ g_cache_remove (c, value);
g_cache_destroy (c);
+ g_free (key);
}
int
g_assert (result);
for (i = 0; i <= items_written; i++)
g_assert (result[i] == ucs4[i]);
+ g_error_free (error3);
}
else if (error_pos)
{
g_assert (result);
for (i = 0; i <= items_written; i++)
g_assert (result[i] == utf16[i]);
+ g_error_free (error3);
}
else if (error_pos)
{
g_assert (items_written == utf8_len);
g_assert (result);
g_assert (strcmp (result, utf8) == 0);
+ g_error_free (error3);
}
else if (error_pos)
{
g_assert (result);
for (i = 0; i <= items_written; i++)
g_assert (result[i] == ucs4[i]);
+ g_error_free (error3);
}
else if (error_pos)
{
g_remove (p2);
g_remove (p1);
g_remove (p0);
+
+ g_free (p2);
+ g_free (p1);
+ g_free (p0);
}
static void
printed = g_variant_print (value, FALSE);
g_assert_cmpstr (tests[i], ==, printed);
g_free (printed);
+ g_variant_unref (value);
}
}
g_mutex_lock (&ctx->lock);
token = ctx->pending_tokens->data;
- ctx->pending_tokens = g_slist_remove_link (ctx->pending_tokens,
+ ctx->pending_tokens = g_slist_delete_link (ctx->pending_tokens,
ctx->pending_tokens);
g_mutex_unlock (&ctx->lock);
GRWLock lock;
g_rw_lock_init (&lock);
+ g_rw_lock_clear (&lock);
return 0;
}
g_assert_cmpint (val, ==, VALUE);
}
+ g_key_file_free (file);
}
static void
g_source_set_priority (source, G_PRIORITY_HIGH);
g_assert (g_source_get_priority (source) == G_PRIORITY_HIGH);
+ g_source_destroy (source);
g_main_context_unref (ctx);
ctx = g_main_context_default ();
g_main_loop_unref (loop);
g_assert (g_main_depth () == 0);
+
+ g_main_loop_unref (loop);
}
static gint a;
if (!g_markup_parse_context_parse (context, contents, length, NULL))
{
g_markup_parse_context_free (context);
+ g_free (contents);
return 1;
}
if (!g_markup_parse_context_end_parse (context, NULL))
{
g_markup_parse_context_free (context);
+ g_free (contents);
return 1;
}
/* A byte at a time */
if (test_in_chunks (contents, length, 1) != 0)
- return 1;
+ {
+ g_free (contents);
+ return 1;
+ }
/* 2 bytes */
if (test_in_chunks (contents, length, 2) != 0)
- return 1;
+ {
+ g_free (contents);
+ return 1;
+ }
/*5 bytes */
if (test_in_chunks (contents, length, 5) != 0)
- return 1;
-
+ {
+ g_free (contents);
+ return 1;
+ }
+
/* 12 bytes */
if (test_in_chunks (contents, length, 12) != 0)
- return 1;
-
+ {
+ g_free (contents);
+ return 1;
+ }
+
/* 1024 bytes */
if (test_in_chunks (contents, length, 1024) != 0)
- return 1;
+ {
+ g_free (contents);
+ return 1;
+ }
+
+ g_free (contents);
return 0;
}
gpointer p, q;
typedef char X[10];
+ /* "FAIL" here apparently means "fail to overflow"... */
#define CHECK_PASS(P) p = (P); g_assert (p == NULL);
#define CHECK_FAIL(P) p = (P); g_assert (p != NULL);
CHECK_PASS (g_try_malloc_n (a, b));
CHECK_PASS (g_try_malloc_n (b, a));
CHECK_FAIL (g_try_malloc_n (b, b));
+ g_free (p);
CHECK_PASS (g_try_malloc0_n (a, a));
CHECK_PASS (g_try_malloc0_n (a, b));
CHECK_PASS (g_try_malloc0_n (b, a));
CHECK_FAIL (g_try_malloc0_n (b, b));
+ g_free (p);
q = g_malloc (1);
CHECK_PASS (g_try_realloc_n (q, a, a));
CHECK_PASS (g_try_realloc_n (q, a, b));
CHECK_PASS (g_try_realloc_n (q, b, a));
CHECK_FAIL (g_try_realloc_n (q, b, b));
- free (p);
+ g_free (p);
CHECK_PASS (g_try_new (X, a));
CHECK_FAIL (g_try_new (X, b));
+ g_free (p);
CHECK_PASS (g_try_new0 (X, a));
CHECK_FAIL (g_try_new0 (X, b));
+ g_free (p);
q = g_try_malloc (1);
CHECK_PASS (g_try_renew (X, q, a));
#undef CHECK_PASS
#define CHECK_FAIL(P) if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR)) { p = (P); exit (0); } g_test_trap_assert_failed();
-#define CHECK_PASS(P) if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR)) { p = (P); exit (0); } g_test_trap_assert_passed();
+
+#define CHECK_PASS(P) do { \
+ if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR)) \
+ { \
+ p = (P); \
+ g_free (p); \
+ exit (0); \
+ } \
+ \
+ g_test_trap_assert_passed(); \
+ } while (0)
CHECK_FAIL (g_malloc_n (a, a));
CHECK_FAIL (g_malloc_n (a, b));
CHECK_FAIL (g_realloc_n (q, a, b));
CHECK_FAIL (g_realloc_n (q, b, a));
CHECK_PASS (g_realloc_n (q, b, b));
- free (q);
+ g_free (q);
CHECK_FAIL (g_new (X, a));
CHECK_PASS (g_new (X, b));
q = g_malloc (1);
CHECK_FAIL (g_renew (X, q, a));
CHECK_PASS (g_renew (X, q, b));
- free (q);
+ g_free (q);
}
typedef struct
for (i = 0; i < g_node_n_children (node_G); i++)
g_assert_cmpint (g_node_child_position (node_G, g_node_nth_child (node_G, i)), ==, i);
+
+ g_node_destroy (root);
}
static void
g_assert (retval == TRUE);
g_assert (strcmp (g_get_prgname(), "option-argv0") == 0
|| strcmp (g_get_prgname (), "lt-option-argv0") == 0);
+
+ g_option_context_free (context);
}
#endif
g_setenv ("LANG", "C", TRUE);
g_option_context_parse (options, &argc, &argv, &error);
+ g_option_context_free (options);
exit(0);
}
else
g_test_trap_assert_stdout_unmatched ("*--help-test*");
}
}
+
+ g_option_context_free (options);
}
}
g_assert_cmpint (passed, ==, 3);
g_assert_cmpint (messages, ==, 3);
+
+ g_free (argv[1]);
+ g_main_loop_unref (loop);
}
static void
g_error ("unexpected log message type: %s", g_test_log_type_name (msg->log_type));
}
}
+
+ g_free (argv[1]);
+ g_main_loop_unref (loop);
}
g_assert_cmpint (messages, ==, 3);
g_assert (g_queue_pop_tail (q) == GINT_TO_POINTER (5));
check_integrity (q);
g_assert_cmpint (g_list_length (q->head), ==, 3);
- g_assert (g_queue_pop_head_link (q)->data == GINT_TO_POINTER (2));
+
+ node = g_queue_pop_head_link (q);
+ g_assert (node->data == GINT_TO_POINTER (2));
+ g_list_free_1 (node);
+
check_integrity (q);
g_assert_cmpint (g_list_length (q->head), ==, 2);
g_assert (g_queue_pop_tail (q) == GINT_TO_POINTER (4));
check_integrity (q);
g_assert_cmpint (g_list_length (q->head), ==, 1);
- g_assert (g_queue_pop_head_link (q)->data == GINT_TO_POINTER (3));
+ node = g_queue_pop_head_link (q);
+ g_assert (node->data == GINT_TO_POINTER (3));
+ g_list_free_1 (node);
check_integrity (q);
g_assert_cmpint (g_list_length (q->head), ==, 0);
g_assert (g_queue_pop_tail (q) == NULL);
node = q->tail;
g_assert (node == g_queue_pop_tail_link (q));
check_integrity (q);
+ g_list_free_1 (node);
g_assert_cmpint (g_list_length (q->head), ==, 3);
data = q->head->data;
g_assert (data == g_queue_pop_head (q));
g_assert (node == NULL);
node = g_queue_pop_nth_link (q, g_queue_get_length (q) - 1);
g_assert (node != NULL && node->data == GINT_TO_POINTER (1234));
+ g_list_free_1 (node);
g_queue_free (q);
}
check_integrity (seq);
}
+
+ for (k = 0; k < N_SEQUENCES; ++k)
+ {
+ g_queue_free (sequences[k].queue);
+ g_sequence_free (sequences[k].sequence);
+ sequences[k].n_items = 0;
+ }
}
/* Random seeds known to have failed at one point
static void
test_strv_length (void)
{
+ gchar **strv;
guint l;
if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
}
g_test_trap_assert_failed ();
- l = g_strv_length (g_strsplit ("1,2,3,4", ",", -1));
+ strv = g_strsplit ("1,2,3,4", ",", -1);
+ l = g_strv_length (strv);
g_assert_cmpuint (l, ==, 4);
+ g_strfreev (strv);
}
static char *locales[] = {"sv_SE", "en_US", "fa_IR", "C", "ru_RU"};
g_string_assign (s, "Mixed Case String !?");
g_string_up (s);
g_assert_cmpstr (s->str, ==, "MIXED CASE STRING !?");
+
+ g_string_free (s, TRUE);
}
static void
g_assert_cmpstr (s->str, ==, "foo");
g_assert_cmpint (s->len, ==, 30);
+
+ g_string_free (s, TRUE);
}
int
g_timeout_add_seconds (21475, function, NULL);
g_main_loop_run (loop);
+ g_main_loop_unref (loop);
}
static gint64 last_time;
g_timeout_add_seconds (1, test_func, NULL);
g_main_loop_run (loop);
+ g_main_loop_unref (loop);
}
int
g_assert_cmpstr (result, ==, "02146538A9CEDB7GIHKMLJOQPSUTRNFWYXacbZegfikjhdmonqsrpuwvzyxtlV");
g_tree_unref (tree);
+ g_free (result);
}
int
g_assert_cmpint (errno, ==, EBADF);
g_assert (!res);
g_assert_error (error, G_UNIX_ERROR, 0);
+ g_clear_error (&error);
}
static gboolean sig_received = FALSE;
g_timeout_add (500, exit_mainloop, mainloop);
g_main_loop_run (mainloop);
g_assert (!sig_received);
+ g_main_loop_unref (mainloop);
}
g_source_remove (id);
kill (getpid (), SIGHUP);
g_assert (!sig_received);
+ g_main_loop_unref (mainloop);
}
g_assert_error (error, G_CONVERT_ERROR, to_uri_tests[i].expected_error);
g_free (res);
+ g_clear_error (&error);
}
}
else
g_assert_error (error, G_CONVERT_ERROR, from_uri_tests[i].expected_error);
g_assert_cmpstr (hostname, ==, from_uri_tests[i].expected_hostname);
+
+ g_free (res);
+ g_free (hostname);
+ g_clear_error (&error);
}
}
g_assert (safe_strcmp_filename (to_uri_tests[i].filename, res) == 0);
g_assert (safe_strcmp_hostname (to_uri_tests[i].hostname, hostname) == 0);
+ g_free (res);
+ g_free (uri);
+ g_free (hostname);
}
}
uris = g_uri_list_extract_uris ("# just hot air\r\n# more hot air");
g_assert_cmpint (g_strv_length (uris), ==, 0);
+ g_strfreev (uris);
}
static void
test_uri_unescape (void)
{
- g_assert_cmpstr (g_uri_unescape_string ("%2Babc %4F", NULL), ==, "+abc O");
+ gchar *s;
+
+ s = g_uri_unescape_string ("%2Babc %4F", NULL);
+ g_assert_cmpstr (s, ==, "+abc O");
+ g_free (s);
g_assert_cmpstr (g_uri_unescape_string ("%2Babc %4F", "+"), ==, NULL);
g_assert_cmpstr (g_uri_unescape_string ("%00abc %4F", "+/"), ==, NULL);
g_assert_cmpstr (g_uri_unescape_string ("%0", NULL), ==, NULL);
g_assert_cmpstr (b->bla, ==, "bla");
g_boxed_free (MY_TYPE_BOXED, b);
+
+ g_free (a.bla);
}
static void
g_param_spec_unref (p2);
g_value_unset (&value);
+ g_param_spec_unref (pp);
}
static gint destroy_count;
g_tree_foreach (tree, my_traverse, NULL);
g_print ("\n");
}
+
+ g_tree_unref (tree);
}
static gboolean
remove (template);
error = NULL;
+ name_used = NULL;
strcpy (template, "zap" G_DIR_SEPARATOR_S "barXXXXXX");
fd = g_file_open_tmp (template, &name_used, &error);
if (g_test_verbose())
if (fd != -1)
close (fd);
g_clear_error (&error);
+ g_free (name_used);
#ifdef G_OS_WIN32
+ name_used = NULL;
strcpy (template, "zap/barXXXXXX");
fd = g_file_open_tmp (template, &name_used, &error);
if (g_test_verbose())
}
close (fd);
g_clear_error (&error);
+ g_free (name_used);
#endif
strcpy (template, "zapXXXXXX");
+ name_used = NULL;
fd = g_file_open_tmp (template, &name_used, &error);
if (fd == -1)
g_error ("g_file_open_tmp didn't work for template '%s': %s\n", template, error->message);
close (fd);
g_clear_error (&error);
remove (name_used);
+ g_free (name_used);
+ name_used = NULL;
fd = g_file_open_tmp (NULL, &name_used, &error);
if (fd == -1)
g_error ("g_file_open_tmp didn't work for a NULL template: %s\n", error->message);
close (fd);
g_clear_error (&error);
remove (name_used);
+ g_free (name_used);
}
static void
}
for (i = 0; i < 10000; i++)
g_mem_chunk_free (mem_chunk, mem[i]);
+
+ g_mem_chunk_destroy (mem_chunk);
}
#endif