diff options
author | Akira TAGOH <akira@tagoh.org> | 2006-11-12 14:29:16 +0000 |
---|---|---|
committer | Akira TAGOH <akira@tagoh.org> | 2006-11-12 14:29:16 +0000 |
commit | be56296ac6c20e55c41118fc08a369280bc4150d (patch) | |
tree | 89ce911ce89fc07ae1e4b6ca8a25c2e44e532b1f /tests | |
parent | efc5c92b3698f17f31cbc225ee06d9729e683600 (diff) |
* hieroglyph/hgmem.c (hg_mem_init): remove GAllocator initialization
code.
(hg_mem_finalize): remove GAllocator finalization code.
(hg_mem_pool_destroy): use HgList instead of GList.
(hg_mem_pool_is_own_object): likewise.
(hg_mem_pool_save_snapshot): save an snapshot image to the list in pool.
(hg_mem_pool_get_age_of_snapshot): new function.
(_hg_mem_set_flags): new function.
(hg_mem_add_root_node): use HgList instead of GList.
(hg_mem_remove_root_node): likewise.
(hg_mem_add_pool_reference): likewise.
(hg_mem_remove_pool_reference): likewise.
* hieroglyph/hgallocator-bfit.c (_hg_allocator_bfit_relocate):
use HgList instead of GList.
(_hg_allocator_bfit_real_set_flags): new function to avoid a fail of
restoring a snapshot when the unused complex objects are freed after
snapping shot, because snapshot image doesn't take care of mere
complex objects.
(_hg_allocator_bfit_real_garbage_collection):
use HgList instead of GList.
(_hg_allocator_bfit_real_restore_snapshot): take an argument to adjust
the amount of objects for the fudge factor.
* hieroglyph/hgmacros.h (HG_MEMOBJ_GET_SNAPSHOT_AGE): add a new macro.
(HG_MEMOBJ_SET_SNAPSHOT_AGE): add a new macro.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/snapshot.c | 30 |
1 files changed, 26 insertions, 4 deletions
diff --git a/tests/snapshot.c b/tests/snapshot.c index 259ab4f..83aff90 100644 --- a/tests/snapshot.c +++ b/tests/snapshot.c @@ -57,13 +57,13 @@ foo(void) node = hg_dict_lookup(dict, key); if (node == NULL || !HG_IS_VALUE_INTEGER (node) || HG_VALUE_GET_INTEGER (node) != 20) { - g_print("Failed to lookup dict."); + g_print("Failed to lookup dict.\n"); return 1; } g_print("restoring snapshot...\n"); - if (!hg_mem_pool_restore_snapshot(pool, snap)) { - g_print("Failed to restore from snapshot."); + if (!hg_mem_pool_restore_snapshot(pool, snap, 0)) { + g_print("Failed to restore from snapshot.\n"); return 1; } node = hg_array_index(array, 0); @@ -79,9 +79,31 @@ foo(void) node = hg_dict_lookup(dict, key); if (node == NULL || !HG_IS_VALUE_BOOLEAN (node) || HG_VALUE_GET_BOOLEAN (node) != TRUE) { - g_print("Failed to lookup dict after restoring."); + g_print("Failed to lookup dict after restoring.\n"); return 1; } + + /* stage 2 */ + g_print("creating snapshot...\n"); + snap = hg_mem_pool_save_snapshot(pool); + string = hg_string_new(pool, 32); + { + HgMemObject *obj; + + hg_mem_get_object__inline(string, obj); + hg_mem_set_lock(obj); + } + if (hg_mem_pool_restore_snapshot(pool, snap, 0)) { + g_print("shouldn't be successful restoring.\n"); + return 1; + } + hg_mem_free(string); + g_print("restoring snapshot...\n"); + if (!hg_mem_pool_restore_snapshot(pool, snap, 0)) { + g_print("Failed to restore from snapshot.\n"); + return 1; + } + hg_mem_pool_destroy(pool); hg_allocator_destroy(allocator); hg_value_node_finalize(); |