[pypy-commit] pypy default: fix test, realloc frees the input ptr if it is realloc() ed
mattip
pypy.commits at gmail.com
Mon Aug 8 13:08:50 EDT 2016
Author: Matti Picus <matti.picus at gmail.com>
Branch:
Changeset: r86086:cffad389be1e
Date: 2016-08-08 20:07 +0300
http://bitbucket.org/pypy/pypy/changeset/cffad389be1e/
Log: fix test, realloc frees the input ptr if it is realloc() ed
diff --git a/pypy/module/cpyext/test/test_object.py b/pypy/module/cpyext/test/test_object.py
--- a/pypy/module/cpyext/test/test_object.py
+++ b/pypy/module/cpyext/test/test_object.py
@@ -245,12 +245,11 @@
char *copy, *orig = PyObject_MALLOC(12);
memcpy(orig, "hello world", 12);
copy = PyObject_REALLOC(orig, 15);
+ /* realloc() takes care of freeing orig, if changed */
if (copy == NULL)
Py_RETURN_NONE;
ret = PyString_FromStringAndSize(copy, 12);
- if (copy != orig)
- PyObject_Free(copy);
- PyObject_Free(orig);
+ PyObject_Free(copy);
return ret;
""")])
x = module.realloctest()
More information about the pypy-commit
mailing list