osutil: use Python memory allocator in _listdir
The Python memory allocator has performance advantages
for small allocations.
--- a/mercurial/osutil.c Thu Mar 09 11:54:25 2017 -0800
+++ b/mercurial/osutil.c Thu Mar 09 11:56:47 2017 -0800
@@ -206,7 +206,7 @@
char *pattern;
/* build the path + \* pattern string */
- pattern = malloc(plen + 3); /* path + \* + \0 */
+ pattern = PyMem_Malloc(plen + 3); /* path + \* + \0 */
if (!pattern) {
PyErr_NoMemory();
goto error_nomem;
@@ -269,7 +269,7 @@
error_list:
FindClose(fh);
error_file:
- free(pattern);
+ PyMem_Free(pattern);
error_nomem:
return rval;
}