Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
cython
Commits
b6b440e6
Commit
b6b440e6
authored
Oct 29, 2009
by
Robert Bradshaw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use plain malloc/free in freezing code
parent
a841345b
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
18 deletions
+18
-18
Cython/Compiler/ModuleNode.py
Cython/Compiler/ModuleNode.py
+9
-9
bin/cython_freeze
bin/cython_freeze
+9
-9
No files found.
Cython/Compiler/ModuleNode.py
View file @
b6b440e6
...
@@ -2579,7 +2579,7 @@ __Pyx_char2wchar(char* arg)
...
@@ -2579,7 +2579,7 @@ __Pyx_char2wchar(char* arg)
mbstate_t mbs;
mbstate_t mbs;
#endif
#endif
if (argsize != (size_t)-1) {
if (argsize != (size_t)-1) {
res = (wchar_t *)
PyMem_M
alloc((argsize+1)*sizeof(wchar_t));
res = (wchar_t *)
m
alloc((argsize+1)*sizeof(wchar_t));
if (!res)
if (!res)
goto oom;
goto oom;
count = mbstowcs(res, arg, argsize+1);
count = mbstowcs(res, arg, argsize+1);
...
@@ -2593,7 +2593,7 @@ __Pyx_char2wchar(char* arg)
...
@@ -2593,7 +2593,7 @@ __Pyx_char2wchar(char* arg)
if (*tmp == 0)
if (*tmp == 0)
return res;
return res;
}
}
PyMem_F
ree(res);
f
ree(res);
}
}
/* Conversion failed. Fall back to escaping with surrogateescape. */
/* Conversion failed. Fall back to escaping with surrogateescape. */
#ifdef HAVE_MBRTOWC
#ifdef HAVE_MBRTOWC
...
@@ -2602,7 +2602,7 @@ __Pyx_char2wchar(char* arg)
...
@@ -2602,7 +2602,7 @@ __Pyx_char2wchar(char* arg)
/* Overallocate; as multi-byte characters are in the argument, the
/* Overallocate; as multi-byte characters are in the argument, the
actual output could use less memory. */
actual output could use less memory. */
argsize = strlen(arg) + 1;
argsize = strlen(arg) + 1;
res =
PyMem_M
alloc(argsize*sizeof(wchar_t));
res =
m
alloc(argsize*sizeof(wchar_t));
if (!res) goto oom;
if (!res) goto oom;
in = (unsigned char*)arg;
in = (unsigned char*)arg;
out = res;
out = res;
...
@@ -2645,7 +2645,7 @@ __Pyx_char2wchar(char* arg)
...
@@ -2645,7 +2645,7 @@ __Pyx_char2wchar(char* arg)
/* Cannot use C locale for escaping; manually escape as if charset
/* Cannot use C locale for escaping; manually escape as if charset
is ASCII (i.e. escape all bytes > 128. This will still roundtrip
is ASCII (i.e. escape all bytes > 128. This will still roundtrip
correctly in the locale's charset, which must be an ASCII superset. */
correctly in the locale's charset, which must be an ASCII superset. */
res =
PyMem_M
alloc((strlen(arg)+1)*sizeof(wchar_t));
res =
m
alloc((strlen(arg)+1)*sizeof(wchar_t));
if (!res) goto oom;
if (!res) goto oom;
in = (unsigned char*)arg;
in = (unsigned char*)arg;
out = res;
out = res;
...
@@ -2665,9 +2665,9 @@ oom:
...
@@ -2665,9 +2665,9 @@ oom:
int
int
main(int argc, char **argv)
main(int argc, char **argv)
{
{
wchar_t **argv_copy = (wchar_t **)
PyMem_M
alloc(sizeof(wchar_t*)*argc);
wchar_t **argv_copy = (wchar_t **)
m
alloc(sizeof(wchar_t*)*argc);
/* We need a second copies, as Python might modify the first one. */
/* We need a second copies, as Python might modify the first one. */
wchar_t **argv_copy2 = (wchar_t **)
PyMem_M
alloc(sizeof(wchar_t*)*argc);
wchar_t **argv_copy2 = (wchar_t **)
m
alloc(sizeof(wchar_t*)*argc);
int i, res;
int i, res;
char *oldloc;
char *oldloc;
if (!argv_copy || !argv_copy2) {
if (!argv_copy || !argv_copy2) {
...
@@ -2685,10 +2685,10 @@ main(int argc, char **argv)
...
@@ -2685,10 +2685,10 @@ main(int argc, char **argv)
free(oldloc);
free(oldloc);
res = __Pyx_main(argc, argv_copy);
res = __Pyx_main(argc, argv_copy);
for (i = 0; i < argc; i++) {
for (i = 0; i < argc; i++) {
PyMem_F
ree(argv_copy2[i]);
f
ree(argv_copy2[i]);
}
}
PyMem_F
ree(argv_copy);
f
ree(argv_copy);
PyMem_F
ree(argv_copy2);
f
ree(argv_copy2);
return res;
return res;
}
}
#endif
#endif
...
...
bin/cython_freeze
View file @
b6b440e6
...
@@ -148,7 +148,7 @@ char2wchar(char* arg)
...
@@ -148,7 +148,7 @@ char2wchar(char* arg)
mbstate_t mbs;
mbstate_t mbs;
#endif
#endif
if (argsize != (size_t)-1) {
if (argsize != (size_t)-1) {
res = (wchar_t *)
PyMem_M
alloc((argsize+1)*sizeof(wchar_t));
res = (wchar_t *)
m
alloc((argsize+1)*sizeof(wchar_t));
if (!res)
if (!res)
goto oom;
goto oom;
count = mbstowcs(res, arg, argsize+1);
count = mbstowcs(res, arg, argsize+1);
...
@@ -162,7 +162,7 @@ char2wchar(char* arg)
...
@@ -162,7 +162,7 @@ char2wchar(char* arg)
if (*tmp == 0)
if (*tmp == 0)
return res;
return res;
}
}
PyMem_F
ree(res);
f
ree(res);
}
}
/* Conversion failed. Fall back to escaping with surrogateescape. */
/* Conversion failed. Fall back to escaping with surrogateescape. */
#ifdef HAVE_MBRTOWC
#ifdef HAVE_MBRTOWC
...
@@ -171,7 +171,7 @@ char2wchar(char* arg)
...
@@ -171,7 +171,7 @@ char2wchar(char* arg)
/* Overallocate; as multi-byte characters are in the argument, the
/* Overallocate; as multi-byte characters are in the argument, the
actual output could use less memory. */
actual output could use less memory. */
argsize = strlen(arg) + 1;
argsize = strlen(arg) + 1;
res =
PyMem_M
alloc(argsize*sizeof(wchar_t));
res =
m
alloc(argsize*sizeof(wchar_t));
if (!res) goto oom;
if (!res) goto oom;
in = (unsigned char*)arg;
in = (unsigned char*)arg;
out = res;
out = res;
...
@@ -214,7 +214,7 @@ char2wchar(char* arg)
...
@@ -214,7 +214,7 @@ char2wchar(char* arg)
/* Cannot use C locale for escaping; manually escape as if charset
/* Cannot use C locale for escaping; manually escape as if charset
is ASCII (i.e. escape all bytes > 128. This will still roundtrip
is ASCII (i.e. escape all bytes > 128. This will still roundtrip
correctly in the locale's charset, which must be an ASCII superset. */
correctly in the locale's charset, which must be an ASCII superset. */
res =
PyMem_M
alloc((strlen(arg)+1)*sizeof(wchar_t));
res =
m
alloc((strlen(arg)+1)*sizeof(wchar_t));
if (!res) goto oom;
if (!res) goto oom;
in = (unsigned char*)arg;
in = (unsigned char*)arg;
out = res;
out = res;
...
@@ -234,9 +234,9 @@ oom:
...
@@ -234,9 +234,9 @@ oom:
int
int
main(int argc, char **argv)
main(int argc, char **argv)
{
{
wchar_t **argv_copy = (wchar_t **)
PyMem_M
alloc(sizeof(wchar_t*)*argc);
wchar_t **argv_copy = (wchar_t **)
m
alloc(sizeof(wchar_t*)*argc);
/* We need a second copies, as Python might modify the first one. */
/* We need a second copies, as Python might modify the first one. */
wchar_t **argv_copy2 = (wchar_t **)
PyMem_M
alloc(sizeof(wchar_t*)*argc);
wchar_t **argv_copy2 = (wchar_t **)
m
alloc(sizeof(wchar_t*)*argc);
int i, res;
int i, res;
char *oldloc;
char *oldloc;
if (!argv_copy || !argv_copy2) {
if (!argv_copy || !argv_copy2) {
...
@@ -254,10 +254,10 @@ main(int argc, char **argv)
...
@@ -254,10 +254,10 @@ main(int argc, char **argv)
free(oldloc);
free(oldloc);
res = python_main(argc, argv_copy);
res = python_main(argc, argv_copy);
for (i = 0; i < argc; i++) {
for (i = 0; i < argc; i++) {
PyMem_F
ree(argv_copy2[i]);
f
ree(argv_copy2[i]);
}
}
PyMem_F
ree(argv_copy);
f
ree(argv_copy);
PyMem_F
ree(argv_copy2);
f
ree(argv_copy2);
return res;
return res;
}
}
#endif"""
#endif"""
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment