osutil: use Python memory allocator in _listdir
authorGregory Szorc <gregory.szorc@gmail.com>
Thu, 09 Mar 2017 11:56:47 -0800
changeset 31468 b9dd03ed564f
parent 31467 08ecec297521
child 31469 a43fd9ec2a39
osutil: use Python memory allocator in _listdir The Python memory allocator has performance advantages for small allocations.
mercurial/osutil.c
--- 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;
 }