]> granicus.if.org Git - python/commitdiff
Remove unnecessary copying in load_long().
authorAlexandre Vassalotti <alexandre@peadrop.com>
Fri, 23 Jan 2009 04:43:46 +0000 (04:43 +0000)
committerAlexandre Vassalotti <alexandre@peadrop.com>
Fri, 23 Jan 2009 04:43:46 +0000 (04:43 +0000)
Modules/_pickle.c

index 02a3e447d9072c392396eeea2e13634c7e272b5f..435969d6762e92bb777f9b17bd8dd1868221cf23 100644 (file)
@@ -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);