From dcd5acc34eacb2024a2b9e7e206717119eea0240 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn=20Nieto?= Date: Tue, 4 Feb 2014 12:45:50 +0100 Subject: [PATCH] index entry: avoid extra copy --- src/index.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/src/index.c b/src/index.c index 5d70a1d..90fae76 100644 --- a/src/index.c +++ b/src/index.c @@ -650,18 +650,12 @@ IndexEntry_path__get__(IndexEntry *self) int IndexEntry_path__set__(IndexEntry *self, PyObject *py_path) { - char *c_inner, *c_path; + char *c_path; - c_inner = py_str_to_c_str(py_path, NULL); - if (!c_inner) + c_path = py_str_to_c_str(py_path, NULL); + if (!c_path) return -1; - c_path = strdup(c_inner); - if (!c_path) { - PyErr_NoMemory(); - return -1; - } - free(self->entry.path); self->entry.path = c_path;