static void _round_lock(sqlx_cache_t *cache) { hashstr_t *hn0 = NULL, *hn1 = NULL; HASHSTR_ALLOCA(hn0, name0); HASHSTR_ALLOCA(hn1, name1); gint id0; GError *err = sqlx_cache_open_and_lock_base(cache, hn0, &id0); g_assert_no_error (err); for (int i=0; i<5 ;i++) { gint id = g_random_int(); err = sqlx_cache_open_and_lock_base(cache, hn0, &id); g_assert_no_error (err); g_assert_cmpint(id0, ==, id); } for (int i=0; i<6 ;i++) { err = sqlx_cache_unlock_and_close_base(cache, id0, FALSE); g_assert_no_error (err); } err = sqlx_cache_unlock_and_close_base(cache, id0, FALSE); g_assert_error (err, GQ(), CODE_INTERNAL_ERROR); g_clear_error (&err); for (int i=0; i<5 ;i++) { gint id = g_random_int (); err = sqlx_cache_open_and_lock_base(cache, hn1, &id); g_assert_no_error (err); err = sqlx_cache_unlock_and_close_base(cache, id, FALSE); g_assert_no_error (err); } }
GTree* meta0_utils_tree_add_url(GTree *tree, const guint8 *b, const gchar *url) { GArray *prefixes; hashstr_t *hu; HASHSTR_ALLOCA(hu, url); prefixes = g_tree_lookup(tree, hu); if (!prefixes) { prefixes = g_array_new(FALSE, FALSE, 2); g_tree_replace(tree, hashstr_dup(hu), prefixes); } g_array_append_vals(prefixes, b, 1); return tree; }
enum service_update_policy_e service_howto_update(struct service_update_policies_s *pol, const gchar *type) { const gchar *dot; struct hashstr_s *htype; EXTRA_ASSERT(pol != NULL); EXTRA_ASSERT(type != NULL); if (NULL != (dot = strchr(type, '.'))) HASHSTR_ALLOCA_LEN(htype, type, (dot-type)); else HASHSTR_ALLOCA(htype, type); return service_howto_update2(pol, htype); }
static void test_regular(sqlx_cache_t *cache) { gint bd = -1; GError *err; hashstr_t *hname = NULL; HASHSTR_ALLOCA(hname, name0); err = sqlx_cache_open_and_lock_base(cache, hname, &bd); if (err != NULL) FAIL(err); g_debug("open(%s) = %d OK", name0, bd); test_lock_unlock(cache, bd); err = sqlx_cache_unlock_and_close_base(cache, bd, FALSE); if (err != NULL) FAIL(err); g_debug("close(%d) OK", bd); }