summaryrefslogtreecommitdiff
path: root/extras
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 /extras
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 'extras')
-rw-r--r--extras/collect/collect.c3
-rw-r--r--extras/volume_id/lib/volume_id.c3
2 files changed, 2 insertions, 4 deletions
diff --git a/extras/collect/collect.c b/extras/collect/collect.c
index 355b85b5cf..3a7e826e4d 100644
--- a/extras/collect/collect.c
+++ b/extras/collect/collect.c
@@ -171,8 +171,7 @@ static int checkout(int fd)
if (debug)
fprintf(stderr, "Found word %s\n", word);
him = malloc(sizeof (struct _mate));
- him->name = malloc(strlen(word) + 1);
- strcpy(him->name, word);
+ him->name = strdup(word);
him->state = STATE_OLD;
udev_list_node_append(&him->node, &bunch);
word = NULL;
diff --git a/extras/volume_id/lib/volume_id.c b/extras/volume_id/lib/volume_id.c
index 791be43515..8f22509ca6 100644
--- a/extras/volume_id/lib/volume_id.c
+++ b/extras/volume_id/lib/volume_id.c
@@ -483,10 +483,9 @@ struct volume_id *volume_id_open_fd(int fd)
{
struct volume_id *id;
- id = malloc(sizeof(struct volume_id));
+ id = calloc(1, sizeof(struct volume_id));
if (id == NULL)
return NULL;
- memset(id, 0x00, sizeof(struct volume_id));
id->fd = fd;