[Python-checkins] r71407 - in python/branches/py3k-short-float-repr: Include/pystrtod.h Objects/complexobject.c
eric.smith
python-checkins at python.org
Thu Apr 9 13:57:59 CEST 2009
Author: eric.smith
Date: Thu Apr 9 13:57:59 2009
New Revision: 71407
Log:
Added a comment about freeing memory returned from PyOS_double_to_string.
Fixed a memory leak in complex_format.
Both thanks to Nick Coghlan's review on Rietveld.
Modified:
python/branches/py3k-short-float-repr/Include/pystrtod.h
python/branches/py3k-short-float-repr/Objects/complexobject.c
Modified: python/branches/py3k-short-float-repr/Include/pystrtod.h
==============================================================================
--- python/branches/py3k-short-float-repr/Include/pystrtod.h (original)
+++ python/branches/py3k-short-float-repr/Include/pystrtod.h Thu Apr 9 13:57:59 2009
@@ -9,6 +9,9 @@
PyAPI_FUNC(double) PyOS_ascii_strtod(const char *str, char **ptr);
PyAPI_FUNC(double) PyOS_ascii_atof(const char *str);
PyAPI_FUNC(char *) PyOS_ascii_formatd(char *buffer, size_t buf_len, const char *format, double d);
+
+/* The caller is responsible for calling PyMem_Free to free the buffer
+ that's is returned. */
PyAPI_FUNC(char *) PyOS_double_to_string(double val,
char format_code,
int precision,
Modified: python/branches/py3k-short-float-repr/Objects/complexobject.c
==============================================================================
--- python/branches/py3k-short-float-repr/Objects/complexobject.c (original)
+++ python/branches/py3k-short-float-repr/Objects/complexobject.c Thu Apr 9 13:57:59 2009
@@ -334,11 +334,11 @@
{
PyObject *result = NULL;
Py_ssize_t len;
- char *buf;
/* If these are non-NULL, they'll need to be freed. */
char *pre = NULL;
char *pim = NULL;
+ char *buf = NULL;
/* These do not need to be freed. They're either aliases for pim
and pre, or pointers to constants. */
@@ -420,6 +420,7 @@
done:
PyMem_Free(pim);
PyMem_Free(pre);
+ PyMem_Free(buf);
return result;
}
More information about the Python-checkins
mailing list