comparison mercurial/parsers.c @ 24575:a62e957413f7

parsers._asciilower: use an explicit return object No functional change, but this will make upcoming patches cleaner.
author Siddharth Agarwal <sid0@fb.com>
date Wed, 01 Apr 2015 13:58:51 -0700
parents e97a00bf18ae
children fe173106e7fe
comparison
equal deleted inserted replaced
24574:e97a00bf18ae 24575:a62e957413f7
96 static inline PyObject *_asciilower(PyObject *str_obj) 96 static inline PyObject *_asciilower(PyObject *str_obj)
97 { 97 {
98 char *str, *newstr; 98 char *str, *newstr;
99 Py_ssize_t i, len; 99 Py_ssize_t i, len;
100 PyObject *newobj = NULL; 100 PyObject *newobj = NULL;
101 PyObject *ret = NULL;
101 102
102 str = PyBytes_AS_STRING(str_obj); 103 str = PyBytes_AS_STRING(str_obj);
103 len = PyBytes_GET_SIZE(str_obj); 104 len = PyBytes_GET_SIZE(str_obj);
104 105
105 newobj = PyBytes_FromStringAndSize(NULL, len); 106 newobj = PyBytes_FromStringAndSize(NULL, len);
119 goto quit; 120 goto quit;
120 } 121 }
121 newstr[i] = lowertable[(unsigned char)c]; 122 newstr[i] = lowertable[(unsigned char)c];
122 } 123 }
123 124
124 return newobj; 125 ret = newobj;
126 Py_INCREF(ret);
125 quit: 127 quit:
126 Py_XDECREF(newobj); 128 Py_XDECREF(newobj);
127 return NULL; 129 return ret;
128 } 130 }
129 131
130 static PyObject *asciilower(PyObject *self, PyObject *args) 132 static PyObject *asciilower(PyObject *self, PyObject *args)
131 { 133 {
132 PyObject *str_obj; 134 PyObject *str_obj;