Пример #1
0
void
write_test_file_for_test_in_use_handle(gboolean in_use_handle)
{
    PersistState *state = clean_and_create_persist_state_for_test("test_in_use.persist");
    PersistEntryHandle handle = persist_state_alloc_entry(state, "alma", sizeof(TestState));
    TestState *test_state = (TestState*) persist_state_map_entry(state, handle);
    test_state->value = 0xDEADBEEF;
    persist_state_unmap_entry(state, handle);

    if (!in_use_handle)
        persist_state_remove_entry(state, "alma");

    commit_and_free_persist_state(state);
}
Пример #2
0
PersistEntryHandle
persist_state_alloc_entry(PersistState *self, const gchar *persist_name, gsize alloc_size)
{
  PersistEntryHandle handle;

  persist_state_remove_entry(self, persist_name);

  handle = _alloc_value(self, alloc_size, TRUE, self->version);
  if (!handle)
    return 0;

  if (!_add_key(self, persist_name, handle))
    {
      _free_value(self, handle);
      return 0;
    }

  return handle;
}
Пример #3
0
void
test_persist_state_remove_entry(void)
{
    guint8 version;
    gsize size;

    PersistState *state = clean_and_create_persist_state_for_test("test_persist_state_remove_entry.persist");

    PersistEntryHandle handle = persist_state_alloc_entry(state, "test", sizeof(TestState));

    handle = persist_state_lookup_entry(state, "test", &size, &version);
    assert_true(handle != 0, "lookup failed before removing entry");

    persist_state_remove_entry(state, "test");

    state = restart_persist_state(state);

    handle = persist_state_lookup_entry(state, "test", &size, &version);
    assert_true(handle == 0, "lookup succeeded after removing entry");

    cancel_and_destroy_persist_state(state);
}