From 0f79e5a5ec1d90109be53c2b2c006bfbe03bd8a8 Mon Sep 17 00:00:00 2001 From: Greg Burd Date: Thu, 28 Mar 2024 19:41:28 -0400 Subject: [PATCH] snapshot v3/p3; WIP --- examples/slm.c | 2 +- include/sl.h | 14 +++++++++----- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/examples/slm.c b/examples/slm.c index b53f82f..7780e04 100644 --- a/examples/slm.c +++ b/examples/slm.c @@ -27,7 +27,7 @@ #define INTEGRITY_CHK ((void)0) #endif -//define SNAPSHOTS +#define SNAPSHOTS #define DOT #define TEST_ARRAY_SIZE 10 diff --git a/include/sl.h b/include/sl.h index 3c4315e..2696311 100644 --- a/include/sl.h +++ b/include/sl.h @@ -1139,10 +1139,14 @@ return rc; \ \ /* (b) shallow copy */ \ - memcpy(dest, src, sizeof(decl##_node_t)); \ + size_t sle_arr_sz = sizeof(struct __skiplist_##decl_entry) * slist->slh_max; \ + memcpy(dest, src, sizeof(decl##_node_t) + sle_arr_sz); \ + \ + /* (d) adjust pointer to sle_next for this node */ \ + dest->field.sle_next = (decl##_node_t **)((uintptr_t)dest + sizeof(decl##_node_t)); \ \ if (!(src == slist->slh_head || src == slist->slh_tail)) { \ - /* (d) deep copy */ \ + /* (e) deep copy */ \ archive_node_blk; \ if (rc) { \ prefix##skip_free_node_##decl(dest); \ @@ -1619,7 +1623,7 @@ if (next) \ fprintf(os, "%p } |", (void *)next); \ else \ - fprintf(os, "0x0 } |"); \ + fprintf(os, "0x0 } |"); \ fflush(os); \ } \ if (fn) { \ @@ -1728,7 +1732,7 @@ if (next) \ fprintf(os, "%p }", (void *)next); \ else \ - fprintf(os, "0x0 }"); \ + fprintf(os, "0x0 }"); \ __SKIP_IS_LAST_ENTRY_T2B() continue; \ fprintf(os, " | "); \ } \ @@ -1776,7 +1780,7 @@ size_t th = slist->slh_head->field.sle_height; \ for (size_t lvl = th; lvl != (size_t)-1; lvl--) { \ next = (node->field.sle_next[lvl] == slist->slh_tail) ? NULL : node->field.sle_next[lvl]; \ - fprintf(os, " 0x0", lvl); \ + fprintf(os, " 0x0", lvl); \ __SKIP_IS_LAST_ENTRY_T2B() continue; \ fprintf(os, " | "); \ } \