summaryrefslogtreecommitdiffstats
path: root/Modules/_pickle.c
diff options
context:
space:
mode:
authorAlexandre Vassalotti <alexandre@peadrop.com>2009-01-23 04:43:46 (GMT)
committerAlexandre Vassalotti <alexandre@peadrop.com>2009-01-23 04:43:46 (GMT)
commit446f7ffa0ff7b89f4ee8f74d4ea7183c8072ecba (patch)
tree864de0772709baba20869b66fe49add6af266197 /Modules/_pickle.c
parentaa069003471ab31c896cec807d7121c6a457aa0e (diff)
downloadcpython-446f7ffa0ff7b89f4ee8f74d4ea7183c8072ecba.zip
cpython-446f7ffa0ff7b89f4ee8f74d4ea7183c8072ecba.tar.gz
cpython-446f7ffa0ff7b89f4ee8f74d4ea7183c8072ecba.tar.bz2
Remove unnecessary copying in load_long().
Diffstat (limited to 'Modules/_pickle.c')
-rw-r--r--Modules/_pickle.c14
1 files changed, 3 insertions, 11 deletions
diff --git a/Modules/_pickle.c b/Modules/_pickle.c
index 02a3e44..435969d 100644
--- a/Modules/_pickle.c
+++ b/Modules/_pickle.c
@@ -2881,7 +2881,7 @@ static int
load_long(UnpicklerObject *self)
{
PyObject *value;
- char *s, *ss;
+ char *s;
Py_ssize_t len;
if ((len = unpickler_readline(self, &s)) < 0)
@@ -2894,17 +2894,9 @@ load_long(UnpicklerObject *self)
compatibility with Python 3.0.0, we don't actually *require*
the 'L' to be present. */
if (s[len-2] == 'L') {
- ss = (char *)PyMem_Malloc(len-1);
- if (ss == NULL) {
- PyErr_NoMemory();
- return -1;
- }
- strncpy(ss, s, len-2);
- ss[len-2] = '\0';
-
+ s[len-2] = '\0';
/* XXX: Should the base argument explicitly set to 10? */
- value = PyLong_FromString(ss, NULL, 0);
- PyMem_Free(ss);
+ value = PyLong_FromString(s, NULL, 0);
}
else {
value = PyLong_FromString(s, NULL, 0);