summaryrefslogtreecommitdiff
path: root/Programs
diff options
context:
space:
mode:
authordoko <doko@ubuntu.com>2017-01-31 13:35:26 +0100
committerdoko <doko@ubuntu.com>2017-01-31 13:35:26 +0100
commite0cb38ac4330d5e09b5e21c74c5d5e453af99a4f (patch)
treea64fe56edb37bb84d4ffea1990c0ac124a6dba9d /Programs
parentd7764ed2a9255ddb5bdb7d3f184610cdc7a66aad (diff)
parent602663ac0effc2e8e3b615141babd95ed7691dda (diff)
downloadcpython-e0cb38ac4330d5e09b5e21c74c5d5e453af99a4f.tar.gz
merge 3.5
Diffstat (limited to 'Programs')
-rw-r--r--Programs/_freeze_importlib.c2
-rw-r--r--Programs/_testembed.c2
-rw-r--r--Programs/python.c9
3 files changed, 11 insertions, 2 deletions
diff --git a/Programs/_freeze_importlib.c b/Programs/_freeze_importlib.c
index 0793984800..1069966a18 100644
--- a/Programs/_freeze_importlib.c
+++ b/Programs/_freeze_importlib.c
@@ -58,7 +58,7 @@ main(int argc, char *argv[])
fprintf(stderr, "cannot fstat '%s'\n", inpath);
goto error;
}
- text_size = status.st_size;
+ text_size = (size_t)status.st_size;
text = (char *) malloc(text_size + 1);
if (text == NULL) {
fprintf(stderr, "could not allocate %ld bytes\n", (long) text_size);
diff --git a/Programs/_testembed.c b/Programs/_testembed.c
index ab6a8c7507..39683993ea 100644
--- a/Programs/_testembed.c
+++ b/Programs/_testembed.c
@@ -41,7 +41,7 @@ static void test_repeated_init_and_subinterpreters(void)
#endif
int i, j;
- for (i=0; i<3; i++) {
+ for (i=0; i<15; i++) {
printf("--- Pass %d ---\n", i);
_testembed_Py_Initialize();
mainstate = PyThreadState_Get();
diff --git a/Programs/python.c b/Programs/python.c
index 37b10b837e..a7afbc774b 100644
--- a/Programs/python.c
+++ b/Programs/python.c
@@ -24,6 +24,9 @@ main(int argc, char **argv)
int i, res;
char *oldloc;
+ /* Force malloc() allocator to bootstrap Python */
+ (void)_PyMem_SetupAllocators("malloc");
+
argv_copy = (wchar_t **)PyMem_RawMalloc(sizeof(wchar_t*) * (argc+1));
argv_copy2 = (wchar_t **)PyMem_RawMalloc(sizeof(wchar_t*) * (argc+1));
if (!argv_copy || !argv_copy2) {
@@ -62,7 +65,13 @@ main(int argc, char **argv)
setlocale(LC_ALL, oldloc);
PyMem_RawFree(oldloc);
+
res = Py_Main(argc, argv_copy);
+
+ /* Force again malloc() allocator to release memory blocks allocated
+ before Py_Main() */
+ (void)_PyMem_SetupAllocators("malloc");
+
for (i = 0; i < argc; i++) {
PyMem_RawFree(argv_copy2[i]);
}