Fix cords for MANUAL_VDB
authorIvan Maidanski <ivmai@mail.ru>
Wed, 23 May 2018 08:43:04 +0000 (11:43 +0300)
committerIvan Maidanski <ivmai@mail.ru>
Wed, 23 May 2018 08:43:04 +0000 (11:43 +0300)
* cord/cordbscs.c (CORD_cat_char_star, CORD CORD_cat,
CORD_from_fn_inner, CORD_substr_closure): Call GC_end_stubborn_change.
* cord/cordxtra.c (refill_cache): Likewise.
* cord/tests/de.c (prune_map, add_map, add_hist, replace_line,
generic_init): Likewise.

cord/cordbscs.c
cord/cordxtra.c
cord/tests/de.c

index 9e6c8ab..864eef9 100644 (file)
@@ -232,6 +232,7 @@ CORD CORD_cat_char_star(CORD x, const char * y, size_t leny)
         result->len = (word)result_len;
         result->left = x;
         result->right = y;
+        GC_end_stubborn_change(result);
         if (depth >= MAX_DEPTH) {
             return(CORD_balance((CORD)result));
         } else {
@@ -273,6 +274,7 @@ CORD CORD_cat(CORD x, CORD y)
         result->len = (word)result_len;
         result->left = x;
         result->right = y;
+        GC_end_stubborn_change(result);
         if (depth >= MAX_DEPTH) {
             return(CORD_balance((CORD)result));
         } else {
@@ -313,6 +315,7 @@ static CordRep *CORD_from_fn_inner(CORD_fn fn, void * client_data, size_t len)
         result->len = (word)len;
         result->fn = fn;
         result->client_data = client_data;
+        GC_end_stubborn_change(result);
         return (CordRep *)result;
     }
 }
@@ -363,6 +366,7 @@ CORD CORD_substr_closure(CORD x, size_t i, size_t n, CORD_fn f)
     if (sa == 0) OUT_OF_MEMORY;
     sa->sa_cord = (CordRep *)x;
     sa->sa_index = i;
+    GC_end_stubborn_change(sa);
     result = CORD_from_fn_inner(f, (void *)sa, n);
     if ((CORD)result != CORD_EMPTY && 0 == result -> function.null)
         result -> function.header = SUBSTR_HDR;
index 5ee4df7..d29f344 100644 (file)
@@ -547,6 +547,8 @@ static char refill_cache(refill_data * client_data)
     new_cache -> tag = DIV_LINE_SZ(file_pos);
     /* Store barrier goes here. */
     ATOMIC_WRITE(state -> lf_cache[line_no], new_cache);
+    GC_end_stubborn_change((/* no volatile */ void *)(state -> lf_cache
+                                                      + line_no));
     state -> lf_current = line_start + LINE_SZ;
     return(new_cache->data[MOD_LINE_SZ(file_pos)]);
 }
index 9d74ae6..cc22df3 100644 (file)
@@ -134,6 +134,7 @@ void prune_map(void)
         current_map_size++;
         if (map -> line < start_line - LINES && map -> previous != 0) {
             map -> previous = map -> previous -> previous;
+            GC_end_stubborn_change(map);
         }
         map = map -> previous;
     } while (map != 0);
@@ -149,6 +150,7 @@ void add_map(int line, size_t pos)
     new_map -> line = line;
     new_map -> pos = pos;
     new_map -> previous = current_map;
+    GC_end_stubborn_change(new_map);
     current_map = new_map;
     current_map_size++;
 }
@@ -194,7 +196,11 @@ void add_hist(CORD s)
     new_file -> file_contents = current = s;
     current_len = CORD_len(s);
     new_file -> previous = now;
-    if (now != 0) now -> map = current_map;
+    GC_end_stubborn_change(new_file);
+    if (now != NULL) {
+        now -> map = current_map;
+        GC_end_stubborn_change(now);
+    }
     now = new_file;
 }
 
@@ -245,6 +251,7 @@ void replace_line(int i, CORD s)
             }
         }
         screen[i] = s;
+        GC_end_stubborn_change(screen + i);
     }
 }
 #else
@@ -566,6 +573,7 @@ void generic_init(void)
     add_hist(initial);
     now -> map = current_map;
     now -> previous = now;  /* Can't back up further: beginning of the world */
+    GC_end_stubborn_change(now);
     need_redisplay = ALL;
     fix_cursor();
 }