snapshot v4/p16; release snapshot

This commit is contained in:
Gregory Burd 2024-03-30 20:36:27 -04:00
parent ae9ad6e9be
commit 65f4bf6bf4
2 changed files with 19 additions and 25 deletions

View file

@ -142,23 +142,25 @@ SKIPLIST_DECL_ACCESS(
/*
* Optional: Snapshots
*
* TODO
* Enable functions that enable returning to an earlier point in
* time when a snapshot was created.
*/
SKIPLIST_DECL_SNAPSHOTS(sample, api_, entries)
/*
* Optional: Archive to/from bytes
*
* TODO
* Enable functions that can write/read the content of your Skiplist
* out/in to/from an array of bytes.
*/
SKIPLIST_DECL_ARCHIVE(sample, api_, entries)
/*
* Optional: As Hashtable
*
* Turn your Skiplist into a hash table. TODO
* Turn your Skiplist into a hash table.
*/
// SKIPLIST_DECL_HASHTABLE(sample, api_, entries, snaps)
//TODO SKIPLIST_DECL_HASHTABLE(sample, api_, entries, snaps)
/*
* Optional: Check Skiplists at runtime
@ -265,7 +267,7 @@ main()
if (list == NULL)
return ENOMEM;
rc = api_skip_init_sample(list, 12); // TODO -12
rc = api_skip_init_sample(list, -12);
if (rc)
return rc;
api_skip_snapshots_init_sample(list);
@ -355,8 +357,8 @@ main()
#endif
#ifdef SNAPSHOTS
// TODO api_skip_restore_snapshot_sample(list, snap_ids[snap_i - 1]);
// TODO api_skip_release_snapshots_sample(list);
//api_skip_restore_snapshot_sample(list, snap_ids[snap_i - 1]);
api_skip_release_snapshots_sample(list);
#endif
assert(strcmp(api_skip_pos_sample(list, SKIP_GTE, -(TEST_ARRAY_SIZE)-1)->value, int_to_roman_numeral(-(TEST_ARRAY_SIZE))) == 0);

View file

@ -1081,13 +1081,22 @@ void __attribute__((format(printf, 4, 5))) __skip_diag_(const char *file, int li
} \
\
/** \
* -- skip_release_snapshots_ TODO \
* -- skip_release_snapshots_ \
* \
*/ \
void prefix##skip_release_snapshots_##decl(decl##_t *slist) \
{ \
decl##_node_t *node, *next; \
if (slist == NULL) \
return; \
\
node = slist->slh_snap.pres; \
while (node) { \
next = node->field.sle_next[0]; \
prefix##skip_free_node_##decl(slist, node); \
node = next; \
} \
slist->slh_snap.era = 0; \
} \
\
/** \
@ -1791,23 +1800,6 @@ void __attribute__((format(printf, 4, 5))) __skip_diag_(const char *file, int li
return prefix##skip_update_##decl(slist, &node); \
} \
\
/** \
* skip_merge_ -- TODO \
* \
* Merges an array of kvp into the list. \
*/ \
int prefix##skip_merge_##decl(decl##_t *slist, ktype *key, vtype *value, size_t len) \
{ \
decl##_node_t *nodes[len]; \
((void)slist); \
((void)key); \
((void)value); \
((void)len); \
((void)nodes); \
int rc = 0; \
return rc; \
} \
\
/** \
* skip_del_ -- \
* \