summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorVincent Labrecque <vincent@cvs.openbsd.org>2003-09-22 23:07:08 +0000
committerVincent Labrecque <vincent@cvs.openbsd.org>2003-09-22 23:07:08 +0000
commit24855bdb7a15be0fa25094e02cfeb9b4cbd54728 (patch)
tree08067f1fa800db9b625410a34c9ec35a911d51ea /usr.bin
parent76f752d949fea53489f80bf9117b6b61a3ca7910 (diff)
canonical realloc
ok tedu henning
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/mg/autoexec.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/usr.bin/mg/autoexec.c b/usr.bin/mg/autoexec.c
index 020b1b6d8d0..f242a5b1ca3 100644
--- a/usr.bin/mg/autoexec.c
+++ b/usr.bin/mg/autoexec.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: autoexec.c,v 1.2 2002/08/22 23:28:19 deraadt Exp $ */
+/* $OpenBSD: autoexec.c,v 1.3 2003/09/22 23:07:07 vincent Exp $ */
/* this file is in the public domain */
/* Author: Vincent Labrecque <vincent@openbsd.org> April 2002 */
@@ -26,7 +26,7 @@ static int ready;
PF *
find_autoexec(const char *fname)
{
- PF *pfl;
+ PF *pfl, *npfl;
int have, used;
struct autoexec *ae;
@@ -39,14 +39,15 @@ find_autoexec(const char *fname)
SLIST_FOREACH(ae, &autos, next) {
if (fnmatch(ae->pattern, fname, 0) == 0) {
if (used >= have) {
- have += 8;
/*
* XXX - realloc(NULL, ...) is not really
* portable
*/
- pfl = realloc(pfl, (have + 1) * sizeof(PF));
- if (pfl == NULL)
+ npfl = realloc(pfl, (have + 8 + 1) * sizeof(PF));
+ if (npfl == NULL)
panic("out of memory");
+ pfl = npfl;
+ have += 8;
}
pfl[used++] = ae->fp;
}