aboutsummaryrefslogtreecommitdiff
path: root/gdb/python
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/python')
-rw-r--r--gdb/python/py-gdb-readline.c5
-rw-r--r--gdb/python/python-internal.h7
2 files changed, 10 insertions, 2 deletions
diff --git a/gdb/python/py-gdb-readline.c b/gdb/python/py-gdb-readline.c
index 8b396db..a02fa8c 100644
--- a/gdb/python/py-gdb-readline.c
+++ b/gdb/python/py-gdb-readline.c
@@ -21,6 +21,7 @@
#include "python-internal.h"
#include "top.h"
#include "cli/cli-utils.h"
+
/* Readline function suitable for PyOS_ReadlineFunctionPointer, which
is used for Python's interactive parser and raw_input. In both
cases, sys_stdin and sys_stdout are always stdin and stdout
@@ -63,7 +64,7 @@ gdbpy_readline_wrapper (FILE *sys_stdin, FILE *sys_stdout,
/* Detect EOF (Ctrl-D). */
if (p == NULL)
{
- q = (char *) PyMem_Malloc (1);
+ q = (char *) PyMem_RawMalloc (1);
if (q != NULL)
q[0] = '\0';
return q;
@@ -72,7 +73,7 @@ gdbpy_readline_wrapper (FILE *sys_stdin, FILE *sys_stdout,
n = strlen (p);
/* Copy the line to Python and return. */
- q = (char *) PyMem_Malloc (n + 2);
+ q = (char *) PyMem_RawMalloc (n + 2);
if (q != NULL)
{
strncpy (q, p, n);
diff --git a/gdb/python/python-internal.h b/gdb/python/python-internal.h
index 908a878..e2ebc1b 100644
--- a/gdb/python/python-internal.h
+++ b/gdb/python/python-internal.h
@@ -172,6 +172,13 @@ typedef unsigned long gdb_py_ulongest;
typedef long Py_hash_t;
#endif
+/* PyMem_RawMalloc appeared in Python 3.4. For earlier versions, we can just
+ fall back to PyMem_Malloc. */
+
+#if PY_VERSION_HEX < 0x03040000
+#define PyMem_RawMalloc PyMem_Malloc
+#endif
+
/* Python 2.6 did not wrap Py_DECREF in 'do {...} while (0)', leading
to 'suggest explicit braces to avoid ambiguous ‘else’' gcc errors.
Wrap it ourselves, so that callers don't need to care. */