diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2014-10-16 19:43:32 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2014-10-16 19:43:32 +0000 |
commit | aabbe96548ee8131cd29f5761c59046dc442e0d2 (patch) | |
tree | 80870401753f3225096220103dfde94a270c54cb /bin/csh/file.c | |
parent | 069c83f247c8063d669a6a74fcc5b0f9f9c5672f (diff) |
Use reallocarray() and remove a few archaic memory allocation practices.
ok deraadt
Diffstat (limited to 'bin/csh/file.c')
-rw-r--r-- | bin/csh/file.c | 11 |
1 files changed, 3 insertions, 8 deletions
diff --git a/bin/csh/file.c b/bin/csh/file.c index c8fa07395ac..11961e6e37a 100644 --- a/bin/csh/file.c +++ b/bin/csh/file.c @@ -1,4 +1,4 @@ -/* $OpenBSD: file.c,v 1.16 2009/10/27 23:59:21 deraadt Exp $ */ +/* $OpenBSD: file.c,v 1.17 2014/10/16 19:43:31 deraadt Exp $ */ /* $NetBSD: file.c,v 1.11 1996/11/08 19:34:37 christos Exp $ */ /*- @@ -450,14 +450,9 @@ again: /* search for matches */ if (command == LIST) { if (numitems >= maxitems) { maxitems += 1024; - if (items == NULL) - items = (Char **) xmalloc(sizeof(*items) * maxitems); - else - items = (Char **) xrealloc((ptr_t) items, - sizeof(*items) * maxitems); + items = xreallocarray(items, maxitems, sizeof(*items)); } - items[numitems] = (Char *) xmalloc((size_t) (Strlen(entry) + 1) * - sizeof(Char)); + items[numitems] = xreallocarray(NULL, (Strlen(entry) + 1), sizeof(Char)); copyn(items[numitems], entry, MAXNAMLEN); numitems++; } |