Author: Remi Meier <[email protected]>
Branch: non-zero-nursery
Changeset: r1722:a514aa39cef8
Date: 2015-03-11 11:49 +0100
http://bitbucket.org/pypy/stmgc/changeset/a514aa39cef8/

Log:    make demos initialize references with NULL after allocation

diff --git a/c8/demo/demo_random.c b/c8/demo/demo_random.c
--- a/c8/demo/demo_random.c
+++ b/c8/demo/demo_random.c
@@ -231,10 +231,14 @@
                            sizeof(struct node_s) + 4096*70};
         size_t size = sizes[get_rand(4)];
         p = stm_allocate(size);
-        ((nodeptr_t)p)->sig = SIGNATURE;
-        ((nodeptr_t)p)->my_size = size;
-        ((nodeptr_t)p)->my_id = 0;
-        ((nodeptr_t)p)->my_hash = 0;
+        nodeptr_t n = (nodeptr_t)p;
+        n->sig = SIGNATURE;
+        n->my_size = size;
+        n->my_id = 0;
+        n->my_hash = 0;
+        nodeptr_t TLPREFIX *last_next = (nodeptr_t TLPREFIX *)((stm_char*)n + 
n->my_size - sizeof(void*));
+        n->next = NULL;
+        *last_next = NULL;
         pop_roots();
         /* reload_roots not necessary, all are old after start_transaction */
         break;
diff --git a/c8/demo/demo_random2.c b/c8/demo/demo_random2.c
--- a/c8/demo/demo_random2.c
+++ b/c8/demo/demo_random2.c
@@ -240,10 +240,14 @@
             sizeof(struct node_s) + (get_rand(100000) & ~15)};
         size_t size = sizes[get_rand(sizeof(sizes) / sizeof(size_t))];
         p = stm_allocate(size);
-        ((nodeptr_t)p)->sig = SIGNATURE;
-        ((nodeptr_t)p)->my_size = size;
-        ((nodeptr_t)p)->my_id = 0;
-        ((nodeptr_t)p)->my_hash = 0;
+        nodeptr_t n = (nodeptr_t)p;
+        n->sig = SIGNATURE;
+        n->my_size = size;
+        n->my_id = 0;
+        n->my_hash = 0;
+        nodeptr_t TLPREFIX *last_next = (nodeptr_t TLPREFIX *)((stm_char*)n + 
n->my_size - sizeof(void*));
+        n->next = NULL;
+        *last_next = NULL;
         pop_roots(pushed);
         break;
     case 4:  // read and validate 'p'
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to