]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
2009-02-27 Phil Muldoon <pmuldoon@redhat.com>
authorPhil Muldoon <pmuldoon@redhat.com>
Fri, 27 Feb 2009 19:33:06 +0000 (19:33 +0000)
committerPhil Muldoon <pmuldoon@redhat.com>
Fri, 27 Feb 2009 19:33:06 +0000 (19:33 +0000)
* valprint.c (read_string): Rework clean-up logic. Use
free_current_contents to clean-up buffer.

gdb/ChangeLog
gdb/valprint.c

index 64c0b53cb635ce17930fd6d01fbb87ebba258365..15c98f911c8b7a9bdbc6fade0bab20d939d83ac6 100644 (file)
@@ -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.
index d13dc4cd20cc03397e8aa49e2b49fccdaa8cc882..b02e9dfd174d1ca523a05746adcdbf6d5bf93db3 100644 (file)
@@ -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;