summaryrefslogtreecommitdiff
path: root/udev/lib/libudev-ctrl.c
diff options
context:
space:
mode:
authorAlan Jenkins <alan-jenkins@tuffmail.co.uk>2008-10-21 11:10:32 +0100
committerKay Sievers <kay.sievers@vrfy.org>2008-10-21 12:54:57 +0200
commitb29a5e4ab98f460d2f79a11d1969858640e897e6 (patch)
treea89a0b059e5b7c365648756ffc76467562030b71 /udev/lib/libudev-ctrl.c
parenta8a8930072c78013bfa4064067242e4826ef837a (diff)
use more appropriate alternatives to malloc()
Use calloc to request cleared memory instead. Kernel and libc conspire to make this more efficient. Also, replace one malloc() + strcpy() with strdup(). Signed-off-by: Alan Jenkins <alan-jenkins@tuffmail.co.uk>
Diffstat (limited to 'udev/lib/libudev-ctrl.c')
-rw-r--r--udev/lib/libudev-ctrl.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/udev/lib/libudev-ctrl.c b/udev/lib/libudev-ctrl.c
index 848f507878..2e15db0be0 100644
--- a/udev/lib/libudev-ctrl.c
+++ b/udev/lib/libudev-ctrl.c
@@ -72,10 +72,9 @@ struct udev_ctrl *udev_ctrl_new_from_socket(struct udev *udev, const char *socke
{
struct udev_ctrl *uctrl;
- uctrl = malloc(sizeof(struct udev_ctrl));
+ uctrl = calloc(1, sizeof(struct udev_ctrl));
if (uctrl == NULL)
return NULL;
- memset(uctrl, 0x00, sizeof(struct udev_ctrl));
uctrl->refcount = 1;
uctrl->udev = udev;
@@ -213,10 +212,9 @@ struct udev_ctrl_msg *udev_ctrl_receive_msg(struct udev_ctrl *uctrl)
struct ucred *cred;
char cred_msg[CMSG_SPACE(sizeof(struct ucred))];
- uctrl_msg = malloc(sizeof(struct udev_ctrl_msg));
+ uctrl_msg = calloc(1, sizeof(struct udev_ctrl_msg));
if (uctrl_msg == NULL)
return NULL;
- memset(uctrl_msg, 0x00, sizeof(struct udev_ctrl_msg));
uctrl_msg->refcount = 1;
uctrl_msg->uctrl = uctrl;