]> granicus.if.org Git - python/commitdiff
correct initialization code (#3376)
authorBenjamin Peterson <benjamin@python.org>
Wed, 6 Sep 2017 03:19:12 +0000 (20:19 -0700)
committerGitHub <noreply@github.com>
Wed, 6 Sep 2017 03:19:12 +0000 (20:19 -0700)
Explicitly initialize struct members rather than relying on compiler extensions.

Python/pylifecycle.c
Python/pystate.c

index f33e920e6b5d9176c5bc1484ba8a50794439d055..3f405b1225a3096def8632e716f41ab970b38e7d 100644 (file)
@@ -77,7 +77,7 @@ extern void _PyGILState_Init(PyInterpreterState *, PyThreadState *);
 extern void _PyGILState_Fini(void);
 #endif /* WITH_THREAD */
 
-_PyRuntimeState _PyRuntime = {};
+_PyRuntimeState _PyRuntime = {0, 0};
 
 void
 _PyRuntime_Initialize(void)
index 3d3207702f8accbb9b1a0e374b20b6d4c0ed08c2..2d926372fd60b2ba9116d9488dd68b71abdfce78 100644 (file)
@@ -37,8 +37,7 @@ extern "C" {
 void
 _PyRuntimeState_Init(_PyRuntimeState *runtime)
 {
-    _PyRuntimeState initial = {};
-    *runtime = initial;
+    memset(runtime, 0, sizeof(*runtime));
 
     _PyObject_Initialize(&runtime->obj);
     _PyMem_Initialize(&runtime->mem);