[PATCH:xscope 03/14] Call realloc() instead of open coding it

Alan Coopersmith alan.coopersmith at oracle.com
Sat Sep 24 08:48:21 PDT 2011


Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>
---
 server.c |    6 +-----
 1 files changed, 1 insertions(+), 5 deletions(-)

diff --git a/server.c b/server.c
index 0943eec..77e77ca 100644
--- a/server.c
+++ b/server.c
@@ -212,13 +212,9 @@ SaveBytes (
     {
       /* not enough room so far; malloc more space and copy */
       long    SizeofNewBytes = (CS[fd].NumberofSavedBytes + n + 1);
-      unsigned char   *NewBytes = malloc (SizeofNewBytes);
+      unsigned char   *NewBytes = realloc (CS[fd].SavedBytes, SizeofNewBytes);
       if (NewBytes == NULL)
 	panic("Can't allocate memory for SavedBytes");
-      bcopy(/* from  */(char *)CS[fd].SavedBytes,
-	    /* to    */(char *)NewBytes,
-	    /* count */(int)CS[fd].SizeofSavedBytes);
-      free(CS[fd].SavedBytes);
       CS[fd].SavedBytes = NewBytes;
       CS[fd].SizeofSavedBytes = SizeofNewBytes;
     }
-- 
1.7.3.2



More information about the xorg-devel mailing list