77// Five distinguishable immortal singletons used as placeholder pointers.
88// These require no reference-count management when stored in a raw array.
99#define NPTRS 5
10- static PyObject * test_objs [NPTRS ] = {
11- Py_None , Py_True , Py_False , Py_Ellipsis , Py_NotImplemented
12- };
10+ static PyObject * test_objs [NPTRS ];
11+
12+ static void
13+ setup_test_objs (void )
14+ {
15+ test_objs [0 ] = Py_None ;
16+ test_objs [1 ] = Py_True ;
17+ test_objs [2 ] = Py_False ;
18+ test_objs [3 ] = Py_Ellipsis ;
19+ test_objs [4 ] = Py_NotImplemented ;
20+ }
21+
1322// Fill buf[0..NPTRS-1] with test_objs in order.
1423static void
1524fill_buf (PyObject * * buf )
@@ -55,6 +64,7 @@ call_memmove(PyObject **dest, PyObject **src, Py_ssize_t n)
5564static PyObject *
5665test_memmove_dest_lt_src (PyObject * self , PyObject * Py_UNUSED (arg ))
5766{
67+ setup_test_objs ();
5868
5969 PyObject * buf [NPTRS ];
6070 fill_buf (buf );
@@ -80,6 +90,7 @@ test_memmove_dest_lt_src(PyObject *self, PyObject *Py_UNUSED(arg))
8090static PyObject *
8191test_memmove_dest_gt_src (PyObject * self , PyObject * Py_UNUSED (arg ))
8292{
93+ setup_test_objs ();
8394
8495 PyObject * buf [NPTRS ];
8596 fill_buf (buf );
@@ -105,6 +116,7 @@ test_memmove_dest_gt_src(PyObject *self, PyObject *Py_UNUSED(arg))
105116static PyObject *
106117test_memmove_dest_eq_src (PyObject * self , PyObject * Py_UNUSED (arg ))
107118{
119+ setup_test_objs ();
108120
109121 PyObject * buf [NPTRS ];
110122 fill_buf (buf );
@@ -129,6 +141,7 @@ test_memmove_dest_eq_src(PyObject *self, PyObject *Py_UNUSED(arg))
129141static PyObject *
130142test_memmove_overlapping (PyObject * self , PyObject * Py_UNUSED (arg ))
131143{
144+ setup_test_objs ();
132145
133146 PyObject * buf [NPTRS ];
134147 fill_buf (buf );
@@ -155,6 +168,7 @@ test_memmove_overlapping(PyObject *self, PyObject *Py_UNUSED(arg))
155168static PyObject *
156169test_memmove_single_owner (PyObject * self , PyObject * Py_UNUSED (arg ))
157170{
171+ setup_test_objs ();
158172
159173 PyObject * a = PyList_New (0 );
160174 if (a == NULL ) {
0 commit comments