aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorPhil Muldoon <pmuldoon@redhat.com>2009-02-27 19:33:06 +0000
committerPhil Muldoon <pmuldoon@redhat.com>2009-02-27 19:33:06 +0000
commitb5096abe11166944e2de1bb8a27a1c36d02a63ef (patch)
tree4250318b3a42f6ef26efd13ccbc2fe9efe94b07b /gdb
parent5b9c60272e18b69b70862cd9ca26e41e5bc8d9c8 (diff)
downloadgdb-b5096abe11166944e2de1bb8a27a1c36d02a63ef.zip
gdb-b5096abe11166944e2de1bb8a27a1c36d02a63ef.tar.gz
gdb-b5096abe11166944e2de1bb8a27a1c36d02a63ef.tar.bz2
2009-02-27 Phil Muldoon <pmuldoon@redhat.com>
* valprint.c (read_string): Rework clean-up logic. Use free_current_contents to clean-up buffer.
Diffstat (limited to 'gdb')
-rw-r--r--gdb/ChangeLog5
-rw-r--r--gdb/valprint.c15
2 files changed, 10 insertions, 10 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 64c0b53..15c98f9 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,8 @@
+2009-02-27 Phil Muldoon <pmuldoon@redhat.com>
+
+ * valprint.c (read_string): Rework clean-up logic. Use
+ free_current_contents to clean-up buffer.
+
2009-02-27 Andreas Schwab <schwab@linux-m68k.org>
* MAINTAINERS: Update e-mail address.
diff --git a/gdb/valprint.c b/gdb/valprint.c
index d13dc4c..b02e9df 100644
--- a/gdb/valprint.c
+++ b/gdb/valprint.c
@@ -1226,13 +1226,14 @@ read_string (CORE_ADDR addr, int len, int width, unsigned int fetchlimit,
some error, such as bumping into the end of the address space. */
found_nul = 0;
- old_chain = make_cleanup (null_cleanup, 0);
+ *buffer = NULL;
+
+ old_chain = make_cleanup (free_current_contents, buffer);
if (len > 0)
{
*buffer = (gdb_byte *) xmalloc (len * width);
bufptr = *buffer;
- old_chain = make_cleanup (xfree, *buffer);
nfetch = partial_memory_read (addr, bufptr, len * width, &errcode)
/ width;
@@ -1243,8 +1244,6 @@ read_string (CORE_ADDR addr, int len, int width, unsigned int fetchlimit,
{
unsigned long bufsize = 0;
- *buffer = NULL;
-
do
{
QUIT;
@@ -1253,13 +1252,9 @@ read_string (CORE_ADDR addr, int len, int width, unsigned int fetchlimit,
if (*buffer == NULL)
*buffer = (gdb_byte *) xmalloc (nfetch * width);
else
- {
- discard_cleanups (old_chain);
- *buffer = (gdb_byte *) xrealloc (*buffer,
- (nfetch + bufsize) * width);
- }
+ *buffer = (gdb_byte *) xrealloc (*buffer,
+ (nfetch + bufsize) * width);
- old_chain = make_cleanup (xfree, *buffer);
bufptr = *buffer + bufsize * width;
bufsize += nfetch;