« Return to Thread: [patch 00/13] [RFC] Hashtable improvements and API changes

[patch 10/13] Adapt to latest hashtable api changes

by Daniel Gollub :: Rate this Message:

Reply to Author | View in Thread

Use reference counting of hashtable.

---
 tests/sync-tests/check_sync.c |  116 +++++++++++++++++++++---------------------
 1 file changed, 58 insertions(+), 58 deletions(-)

Index: tests/sync-tests/check_sync.c
===================================================================
--- tests/sync-tests/check_sync.c.orig
+++ tests/sync-tests/check_sync.c
@@ -137,13 +137,13 @@ START_TEST (sync_easy_new)
     OSyncHashTable *table = hashtable_load(path, "mockobjtype1", 1);
  g_free(path);
     check_hash(table, "testdata");
- osync_hashtable_free(table);
+ osync_hashtable_unref(table);
 
  path = g_strdup_printf("%s/configs/group/2/hashtable.db", testbed);
     table = hashtable_load(path, "mockobjtype1", 1);
  g_free(path);
     check_hash(table, "testdata");
- osync_hashtable_free(table);
+ osync_hashtable_unref(table);
 
  destroy_testbed(testbed);
 }
@@ -197,13 +197,13 @@ START_TEST (sync_easy_new_del)
     OSyncHashTable *table = hashtable_load(path, "mockobjtype1", 1);
  g_free(path);
     check_hash(table, "testdata");
- osync_hashtable_free(table);
+ osync_hashtable_unref(table);
 
  path = g_strdup_printf("%s/configs/group/2/hashtable.db", testbed);
     table = hashtable_load(path, "mockobjtype1", 1);
  g_free(path);
     check_hash(table, "testdata");
- osync_hashtable_free(table);
+ osync_hashtable_unref(table);
 
  reset_counters();
  system("rm data1/testdata");
@@ -262,12 +262,12 @@ START_TEST (sync_easy_new_del)
  path = g_strdup_printf("%s/configs/group/1/hashtable.db", testbed);
     table = hashtable_load(path, "mockobjtype1", 0);
  g_free(path);
- osync_hashtable_free(table);
+ osync_hashtable_unref(table);
 
  path = g_strdup_printf("%s/configs/group/2/hashtable.db", testbed);
     table = hashtable_load(path, "mockobjtype1", 0);
  g_free(path);
- osync_hashtable_free(table);
+ osync_hashtable_unref(table);
 
  destroy_testbed(testbed);
 }
@@ -365,13 +365,13 @@ START_TEST (sync_easy_conflict)
     OSyncHashTable *table = hashtable_load(path, "mockobjtype1", 1);
  g_free(path);
     check_hash(table, "testdata");
- osync_hashtable_free(table);
+ osync_hashtable_unref(table);
 
  path = g_strdup_printf("%s/configs/group/2/hashtable.db", testbed);
     table = hashtable_load(path, "mockobjtype1", 1);
  g_free(path);
     check_hash(table, "testdata");
- osync_hashtable_free(table);
+ osync_hashtable_unref(table);
 
  destroy_testbed(testbed);
 }
@@ -461,13 +461,13 @@ START_TEST (sync_easy_new_mapping)
     OSyncHashTable *table = hashtable_load(path, "mockobjtype1", 1);
  g_free(path);
     check_hash(table, "testdata");
- osync_hashtable_free(table);
+ osync_hashtable_unref(table);
 
  path = g_strdup_printf("%s/configs/group/2/hashtable.db", testbed);
     table = hashtable_load(path, "mockobjtype1", 1);
  g_free(path);
     check_hash(table, "testdata");
- osync_hashtable_free(table);
+ osync_hashtable_unref(table);
 
  reset_counters();
  system("rm data1/testdata");
@@ -526,12 +526,12 @@ START_TEST (sync_easy_new_mapping)
  path = g_strdup_printf("%s/configs/group/1/hashtable.db", testbed);
     table = hashtable_load(path, "mockobjtype1", 0);
  g_free(path);
- osync_hashtable_free(table);
+ osync_hashtable_unref(table);
 
  path = g_strdup_printf("%s/configs/group/2/hashtable.db", testbed);
     table = hashtable_load(path, "mockobjtype1", 0);
  g_free(path);
- osync_hashtable_free(table);
+ osync_hashtable_unref(table);
 
  destroy_testbed(testbed);
 }
@@ -624,14 +624,14 @@ START_TEST (sync_easy_conflict_duplicate
  g_free(path);
     check_hash(table, "testdata");
     check_hash(table, "testdata-dupe");
- osync_hashtable_free(table);
+ osync_hashtable_unref(table);
 
  path = g_strdup_printf("%s/configs/group/2/hashtable.db", testbed);
     table = hashtable_load(path, "mockobjtype1", 2);
  g_free(path);
     check_hash(table, "testdata");
     check_hash(table, "testdata-dupe");
- osync_hashtable_free(table);
+ osync_hashtable_unref(table);
 
  fail_unless(!system("test \"x$(diff -x \".*\" data1 data2)\" = \"x\""), NULL);
  system("rm -f data1/testdata-dupe");
@@ -695,13 +695,13 @@ START_TEST (sync_easy_conflict_duplicate
     table = hashtable_load(path, "mockobjtype1", 1);
  g_free(path);
     check_hash(table, "testdata");
- osync_hashtable_free(table);
+ osync_hashtable_unref(table);
 
  path = g_strdup_printf("%s/configs/group/2/hashtable.db", testbed);
     table = hashtable_load(path, "mockobjtype1", 1);
  g_free(path);
     check_hash(table, "testdata");
- osync_hashtable_free(table);
+ osync_hashtable_unref(table);
 
  destroy_testbed(testbed);
 }
@@ -797,14 +797,14 @@ START_TEST (sync_easy_conflict_abort)
  g_free(path);
     check_hash(table, "testdata");
  //   check_hash(table, "testdata-dupe");
- osync_hashtable_free(table);
+ osync_hashtable_unref(table);
 
  path = g_strdup_printf("%s/configs/group/2/hashtable.db", testbed);
     table = hashtable_load(path, "mockobjtype1", 1);
  g_free(path);
     check_hash(table, "testdata");
    // check_hash(table, "testdata-dupe");
- osync_hashtable_free(table);
+ osync_hashtable_unref(table);
 
  fail_unless(!system("test \"x$(diff -x \".*\" data1 data2)\" != \"x\""), NULL);
 // system("rm -f data1/testdata-dupe");
@@ -870,13 +870,13 @@ START_TEST (sync_easy_conflict_abort)
     table = hashtable_load(path, "mockobjtype1", 1);
  g_free(path);
     check_hash(table, "testdata");
- osync_hashtable_free(table);
+ osync_hashtable_unref(table);
 
  path = g_strdup_printf("%s/configs/group/2/hashtable.db", testbed);
     table = hashtable_load(path, "mockobjtype1", 1);
  g_free(path);
     check_hash(table, "testdata");
- osync_hashtable_free(table);
+ osync_hashtable_unref(table);
 
  destroy_testbed(testbed);
 }
@@ -1036,14 +1036,14 @@ START_TEST (sync_conflict_duplicate2)
  g_free(path);
     check_hash(table, "testdata");
     check_hash(table, "testdata-dupe");
- osync_hashtable_free(table);
+ osync_hashtable_unref(table);
 
  path = g_strdup_printf("%s/configs/group/2/hashtable.db", testbed);
     table = hashtable_load(path, "mockobjtype1", 2);
  g_free(path);
     check_hash(table, "testdata");
     check_hash(table, "testdata-dupe");
- osync_hashtable_free(table);
+ osync_hashtable_unref(table);
 
 
  system("rm -f data1/testdata");
@@ -1111,13 +1111,13 @@ START_TEST (sync_conflict_duplicate2)
     table = hashtable_load(path, "mockobjtype1", 1);
  g_free(path);
     check_hash(table, "testdata");
- osync_hashtable_free(table);
+ osync_hashtable_unref(table);
 
  path = g_strdup_printf("%s/configs/group/2/hashtable.db", testbed);
     table = hashtable_load(path, "mockobjtype1", 1);
  g_free(path);
     check_hash(table, "testdata");
- osync_hashtable_free(table);
+ osync_hashtable_unref(table);
 
  destroy_testbed(testbed);
 }
@@ -1218,7 +1218,7 @@ START_TEST (sync_conflict_delay)
     check_hash(table, "testdata1");
     check_hash(table, "testdata2");
     check_hash(table, "testdata3");
- osync_hashtable_free(table);
+ osync_hashtable_unref(table);
 
  path = g_strdup_printf("%s/configs/group/2/hashtable.db", testbed);
     table = hashtable_load(path, "mockobjtype1", 3);
@@ -1226,7 +1226,7 @@ START_TEST (sync_conflict_delay)
     check_hash(table, "testdata1");
     check_hash(table, "testdata2");
     check_hash(table, "testdata3");
- osync_hashtable_free(table);
+ osync_hashtable_unref(table);
 
  system("rm -f data1/testdata1");
  system("rm -f data2/testdata2");
@@ -1287,12 +1287,12 @@ START_TEST (sync_conflict_delay)
  path = g_strdup_printf("%s/configs/group/1/hashtable.db", testbed);
     table = hashtable_load(path, "mockobjtype1", 0);
  g_free(path);
- osync_hashtable_free(table);
+ osync_hashtable_unref(table);
 
  path = g_strdup_printf("%s/configs/group/2/hashtable.db", testbed);
     table = hashtable_load(path, "mockobjtype1", 0);
  g_free(path);
- osync_hashtable_free(table);
+ osync_hashtable_unref(table);
 
  destroy_testbed(testbed);
 }
@@ -1391,12 +1391,12 @@ START_TEST (sync_conflict_deldel)
  path = g_strdup_printf("%s/configs/group/1/hashtable.db", testbed);
     OSyncHashTable *table = hashtable_load(path, "mockobjtype1", 0);
  g_free(path);
- osync_hashtable_free(table);
+ osync_hashtable_unref(table);
 
  path = g_strdup_printf("%s/configs/group/2/hashtable.db", testbed);
     table = hashtable_load(path, "mockobjtype1", 0);
  g_free(path);
- osync_hashtable_free(table);
+ osync_hashtable_unref(table);
 
  destroy_testbed(testbed);
 }
@@ -1495,13 +1495,13 @@ START_TEST (sync_moddel)
     OSyncHashTable *table = hashtable_load(path, "mockobjtype1", 1);
  g_free(path);
     check_hash(table, "testdata");
- osync_hashtable_free(table);
+ osync_hashtable_unref(table);
 
  path = g_strdup_printf("%s/configs/group/2/hashtable.db", testbed);
     table = hashtable_load(path, "mockobjtype1", 1);
  g_free(path);
     check_hash(table, "testdata");
- osync_hashtable_free(table);
+ osync_hashtable_unref(table);
 
  reset_counters();
 
@@ -1560,12 +1560,12 @@ START_TEST (sync_moddel)
  path = g_strdup_printf("%s/configs/group/1/hashtable.db", testbed);
     table = hashtable_load(path, "mockobjtype1", 0);
  g_free(path);
- osync_hashtable_free(table);
+ osync_hashtable_unref(table);
 
  path = g_strdup_printf("%s/configs/group/2/hashtable.db", testbed);
     table = hashtable_load(path, "mockobjtype1", 0);
  g_free(path);
- osync_hashtable_free(table);
+ osync_hashtable_unref(table);
 
  destroy_testbed(testbed);
 }
@@ -1666,12 +1666,12 @@ START_TEST (sync_conflict_moddel)
  path = g_strdup_printf("%s/configs/group/1/hashtable.db", testbed);
     OSyncHashTable *table = hashtable_load(path, "mockobjtype1", 0);
  g_free(path);
- osync_hashtable_free(table);
+ osync_hashtable_unref(table);
 
  path = g_strdup_printf("%s/configs/group/2/hashtable.db", testbed);
     table = hashtable_load(path, "mockobjtype1", 0);
  g_free(path);
- osync_hashtable_free(table);
+ osync_hashtable_unref(table);
 
  fail_unless(!system("test \"x$(ls data1)\" = \"x\""), NULL);
  fail_unless(!system("test \"x$(ls data2)\" = \"x\""), NULL);
@@ -1768,14 +1768,14 @@ START_TEST (sync_easy_dualdel)
  g_free(path);
     check_hash(table, "testdata");
     check_hash(table, "testdata2");
- osync_hashtable_free(table);
+ osync_hashtable_unref(table);
 
  path = g_strdup_printf("%s/configs/group/2/hashtable.db", testbed);
     table = hashtable_load(path, "mockobjtype1", 2);
  g_free(path);
     check_hash(table, "testdata");
     check_hash(table, "testdata2");
- osync_hashtable_free(table);
+ osync_hashtable_unref(table);
 
  reset_counters();
 
@@ -1836,12 +1836,12 @@ START_TEST (sync_easy_dualdel)
  path = g_strdup_printf("%s/configs/group/1/hashtable.db", testbed);
     table = hashtable_load(path, "mockobjtype1", 0);
  g_free(path);
- osync_hashtable_free(table);
+ osync_hashtable_unref(table);
 
  path = g_strdup_printf("%s/configs/group/2/hashtable.db", testbed);
     table = hashtable_load(path, "mockobjtype1", 0);
  g_free(path);
- osync_hashtable_free(table);
+ osync_hashtable_unref(table);
 
  fail_unless(!system("test \"x$(ls data1)\" = \"x\""), NULL);
  fail_unless(!system("test \"x$(ls data2)\" = \"x\""), NULL);
@@ -1974,7 +1974,7 @@ START_TEST (sync_large)
     check_hash(table, "file8");
     check_hash(table, "file9");
     check_hash(table, "file10");
- osync_hashtable_free(table);
+ osync_hashtable_unref(table);
 
  path = g_strdup_printf("%s/configs/group/2/hashtable.db", testbed);
     table = hashtable_load(path, "mockobjtype1", 10);
@@ -1989,7 +1989,7 @@ START_TEST (sync_large)
     check_hash(table, "file8");
     check_hash(table, "file9");
     check_hash(table, "file10");
- osync_hashtable_free(table);
+ osync_hashtable_unref(table);
 
  reset_counters();
 
@@ -2107,7 +2107,7 @@ START_TEST (sync_large)
     check_hash(table, "file12");
     check_hash(table, "file13");
     check_hash(table, "file14");
- osync_hashtable_free(table);
+ osync_hashtable_unref(table);
 
  path = g_strdup_printf("%s/configs/group/2/hashtable.db", testbed);
     table = hashtable_load(path, "mockobjtype1", 10);
@@ -2122,7 +2122,7 @@ START_TEST (sync_large)
     check_hash(table, "file12");
     check_hash(table, "file13");
     check_hash(table, "file14");
- osync_hashtable_free(table);
+ osync_hashtable_unref(table);
 
 
  reset_counters();
@@ -2198,12 +2198,12 @@ START_TEST (sync_large)
  path = g_strdup_printf("%s/configs/group/1/hashtable.db", testbed);
     table = hashtable_load(path, "mockobjtype1", 0);
  g_free(path);
- osync_hashtable_free(table);
+ osync_hashtable_unref(table);
 
  path = g_strdup_printf("%s/configs/group/2/hashtable.db", testbed);
     table = hashtable_load(path, "mockobjtype1", 0);
  g_free(path);
- osync_hashtable_free(table);
+ osync_hashtable_unref(table);
 
  fail_unless(!system("test \"x$(ls data1)\" = \"x\""), NULL);
  fail_unless(!system("test \"x$(ls data2)\" = \"x\""), NULL);
@@ -2403,13 +2403,13 @@ START_TEST (sync_detect_obj)
     OSyncHashTable *table = hashtable_load(path, "mockobjtype1", 1);
  g_free(path);
     check_hash(table, "file1");
- osync_hashtable_free(table);
+ osync_hashtable_unref(table);
 
  path = g_strdup_printf("%s/configs/group/2/hashtable.db", testbed);
     table = hashtable_load(path, "mockobjtype1", 1);
  g_free(path);
     check_hash(table, "file1");
- osync_hashtable_free(table);
+ osync_hashtable_unref(table);
 
  destroy_testbed(testbed);
 }
@@ -2601,13 +2601,13 @@ START_TEST (sync_detect_obj2)
     OSyncHashTable *table = hashtable_load(path, "mockobjtype1", 1);
  g_free(path);
     check_hash(table, "file1");
- osync_hashtable_free(table);
+ osync_hashtable_unref(table);
 
  path = g_strdup_printf("%s/configs/group/2/hashtable.db", testbed);
     table = hashtable_load(path, "mockobjtype1", 1);
  g_free(path);
     check_hash(table, "file1");
- osync_hashtable_free(table);
+ osync_hashtable_unref(table);
 
  destroy_testbed(testbed);
 }
@@ -2704,13 +2704,13 @@ START_TEST (sync_slowsync_connect)
     OSyncHashTable *table = hashtable_load(path, "mockobjtype1", 1);
  g_free(path);
     check_hash(table, "testdata");
- osync_hashtable_free(table);
+ osync_hashtable_unref(table);
 
  path = g_strdup_printf("%s/configs/group/2/hashtable.db", testbed);
     table = hashtable_load(path, "mockobjtype1", 1);
  g_free(path);
     check_hash(table, "testdata");
- osync_hashtable_free(table);
+ osync_hashtable_unref(table);
 
  /* 2nd Sync with new path config for #1 member - this is needed
  * to trigger a slow-sync within the connect() plugin call. */
@@ -2800,13 +2800,13 @@ START_TEST (sync_slowsync_connect)
     table = hashtable_load(path, "mockobjtype1", 1);
  g_free(path);
     check_hash(table, "testdata");
- osync_hashtable_free(table);
+ osync_hashtable_unref(table);
 
  path = g_strdup_printf("%s/configs/group/2/hashtable.db", testbed);
     table = hashtable_load(path, "mockobjtype1", 1);
  g_free(path);
     check_hash(table, "testdata");
- osync_hashtable_free(table);
+ osync_hashtable_unref(table);
 
  destroy_testbed(testbed);
 }
@@ -2906,13 +2906,13 @@ START_TEST (sync_slowsync_mainsink_conne
     OSyncHashTable *table = hashtable_load(path, "mockobjtype1", 1);
  g_free(path);
     check_hash(table, "testdata");
- osync_hashtable_free(table);
+ osync_hashtable_unref(table);
 
  path = g_strdup_printf("%s/configs/group/2/hashtable.db", testbed);
     table = hashtable_load(path, "mockobjtype1", 1);
  g_free(path);
     check_hash(table, "testdata");
- osync_hashtable_free(table);
+ osync_hashtable_unref(table);
 
  /* 2nd Sync trigger a SlowSync within the MAINSINK connect function. */
  reset_counters();
@@ -3001,13 +3001,13 @@ START_TEST (sync_slowsync_mainsink_conne
     table = hashtable_load(path, "mockobjtype1", 1);
  g_free(path);
     check_hash(table, "testdata");
- osync_hashtable_free(table);
+ osync_hashtable_unref(table);
 
  path = g_strdup_printf("%s/configs/group/2/hashtable.db", testbed);
     table = hashtable_load(path, "mockobjtype1", 1);
  g_free(path);
     check_hash(table, "testdata");
- osync_hashtable_free(table);
+ osync_hashtable_unref(table);
 
  destroy_testbed(testbed);
 }


-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
Don't miss this year's exciting event. There's still time to save $100.
Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
Opensync-devel mailing list
Opensync-devel@...
https://lists.sourceforge.net/lists/listinfo/opensync-devel

 « Return to Thread: [patch 00/13] [RFC] Hashtable improvements and API changes

LightInTheBox - Buy quality products at wholesale price