From 4acfec7c03865144491f913694f8dca17072d13e Mon Sep 17 00:00:00 2001 From: Alan Coopersmith Date: Fri, 30 Sep 2011 20:19:44 -0700 Subject: Call realloc() instead of open coding it Signed-off-by: Alan Coopersmith Reviewed-by: Jeremy Huddleston --- server.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'server.c') 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; } -- cgit v1.2.1