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

Alan Coopersmith alan.coopersmith at oracle.com
Sun Dec 8 12:30:47 PST 2013


Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>
---
 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



More information about the xorg-devel mailing list