Allocate alias pointers for qsort() to use on the stack, rather than
directly via malloc() so they get cleaned up correctly on error/intr. NFCI.
This commit is contained in:
parent
f384630a8c
commit
3dbd860142
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: alias.c,v 1.20 2018/12/03 06:40:26 kre Exp $ */
|
/* $NetBSD: alias.c,v 1.21 2019/02/09 09:11:07 kre Exp $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 1993
|
* Copyright (c) 1993
|
||||||
|
@ -37,7 +37,7 @@
|
||||||
#if 0
|
#if 0
|
||||||
static char sccsid[] = "@(#)alias.c 8.3 (Berkeley) 5/4/95";
|
static char sccsid[] = "@(#)alias.c 8.3 (Berkeley) 5/4/95";
|
||||||
#else
|
#else
|
||||||
__RCSID("$NetBSD: alias.c,v 1.20 2018/12/03 06:40:26 kre Exp $");
|
__RCSID("$NetBSD: alias.c,v 1.21 2019/02/09 09:11:07 kre Exp $");
|
||||||
#endif
|
#endif
|
||||||
#endif /* not lint */
|
#endif /* not lint */
|
||||||
|
|
||||||
|
@ -63,7 +63,7 @@ STATIC void list_aliases(void);
|
||||||
STATIC int unalias(char *);
|
STATIC int unalias(char *);
|
||||||
STATIC struct alias **freealias(struct alias **, int);
|
STATIC struct alias **freealias(struct alias **, int);
|
||||||
STATIC struct alias **hashalias(const char *);
|
STATIC struct alias **hashalias(const char *);
|
||||||
STATIC size_t countaliases(void);
|
STATIC int countaliases(void);
|
||||||
|
|
||||||
STATIC
|
STATIC
|
||||||
void
|
void
|
||||||
|
@ -196,13 +196,13 @@ by_name(const void *a, const void *b)
|
||||||
STATIC void
|
STATIC void
|
||||||
list_aliases(void)
|
list_aliases(void)
|
||||||
{
|
{
|
||||||
size_t i, j, n;
|
int i, j, n;
|
||||||
const struct alias **aliases;
|
const struct alias **aliases;
|
||||||
const struct alias *ap;
|
const struct alias *ap;
|
||||||
|
|
||||||
INTOFF;
|
INTOFF;
|
||||||
n = countaliases();
|
n = countaliases();
|
||||||
aliases = ckmalloc(n * sizeof aliases[0]);
|
aliases = stalloc(n * (int)(sizeof aliases[0]));
|
||||||
|
|
||||||
j = 0;
|
j = 0;
|
||||||
for (i = 0; i < ATABSIZE; i++)
|
for (i = 0; i < ATABSIZE; i++)
|
||||||
|
@ -221,7 +221,7 @@ list_aliases(void)
|
||||||
out1c('\n');
|
out1c('\n');
|
||||||
}
|
}
|
||||||
|
|
||||||
ckfree(aliases);
|
stunalloc(aliases);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -230,7 +230,7 @@ list_aliases(void)
|
||||||
* Use this opportunity to clean up any of those
|
* Use this opportunity to clean up any of those
|
||||||
* zombies that are no longer needed.
|
* zombies that are no longer needed.
|
||||||
*/
|
*/
|
||||||
STATIC size_t
|
STATIC int
|
||||||
countaliases(void)
|
countaliases(void)
|
||||||
{
|
{
|
||||||
struct alias *ap, **app;
|
struct alias *ap, **app;
|
||||||
|
|
Loading…
Reference in New Issue