[PATCH 2/3] Replace "if(buf) realloc(buf, size) else malloc(size)" with realloc()

Alan Coopersmith alan.coopersmith at oracle.com
Sun Oct 24 14:36:11 PDT 2010


Mikhail Gusarov wrote:
> Signed-off-by: Mikhail Gusarov <dottedmag at dottedmag.net>
> ---
>  os/log.c |    5 +----
>  1 files changed, 1 insertions(+), 4 deletions(-)
> 
> diff --git a/os/log.c b/os/log.c
> index 3435da6..94f76aa 100644
> --- a/os/log.c
> +++ b/os/log.c
> @@ -305,10 +305,7 @@ LogVWrite(int verb, const char *f, va_list args)
>  	    if (len > bufferUnused) {
>  		bufferSize += 1024;
>  		bufferUnused += 1024;
> -		if (saveBuffer)
> -		    saveBuffer = realloc(saveBuffer, bufferSize);
> -		else
> -		    saveBuffer = malloc(bufferSize);
> +                saveBuffer = realloc(saveBuffer, bufferSize);
>  		if (!saveBuffer)
>  		    FatalError("realloc() failed while saving log messages\n");
>  	    }

The spacing doesn't line up, but the code looks correct, so if you can make the
new saveBuffer line match the indentation of the lines before & after it:

Reviewed-by: Alan Coopersmith <alan.coopersmith at oracle.com>

-- 
	-Alan Coopersmith-        alan.coopersmith at oracle.com
	 Oracle Solaris Platform Engineering: X Window System



More information about the xorg-devel mailing list