[PATCH:libdmx] Replace malloc(size); memset(...,0,size) with calloc

Peter Hutterer peter.hutterer at who-t.net
Sun Dec 8 15:53:18 PST 2013


On Sun, Dec 08, 2013 at 12:30:47PM -0800, Alan Coopersmith wrote:
> Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>

Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>

Cheers,
   Peter

> ---
>  src/dmx.c |    6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/src/dmx.c b/src/dmx.c
> index 5ef0ed4..7e1f953 100644
> --- a/src/dmx.c
> +++ b/src/dmx.c
> @@ -440,8 +440,7 @@ Bool DMXAddScreen(Display *dpy, const char *displayName, unsigned int mask,
>      req->length           += _DMXDumpScreenAttributes(dpy, mask, attr);
>  
>      if (length) {
> -        char *buffer       = Xmalloc(paddedLength);
> -        memset(buffer, 0, paddedLength);
> +        char *buffer       = Xcalloc(paddedLength, 1);
>          memcpy(buffer, displayName, length);
>          Data32(dpy, buffer, paddedLength);
>          Xfree(buffer);
> @@ -780,8 +779,7 @@ Bool DMXAddInput(Display *dpy, unsigned int mask, DMXInputAttributes *attr,
>      req->length           += _DMXDumpInputAttributes(dpy, mask, attr);
>  
>      if (length) {
> -        char *buffer       = Xmalloc(paddedLength);
> -        memset(buffer, 0, paddedLength);
> +        char *buffer       = Xcalloc(paddedLength, 1);
>          memcpy(buffer, attr->name, paddedLength);
>          Data32(dpy, buffer, paddedLength);
>          Xfree(buffer);
> -- 
> 1.7.9.2
> 
> _______________________________________________
> xorg-devel at lists.x.org: X.Org development
> Archives: http://lists.x.org/archives/xorg-devel
> Info: http://lists.x.org/mailman/listinfo/xorg-devel
> 


More information about the xorg-devel mailing list