From 77b6f43a9626ed1939a626ec91936ac78d1415cb Mon Sep 17 00:00:00 2001 From: Thomas Bushnell Date: Fri, 5 Mar 1999 22:21:53 +0000 Subject: Fri Mar 5 17:13:04 1999 Thomas Bushnell, BSG * primes.c (_ihash_nextprime): Use a dynamically-sized array for `seive' instead of alloca, so that if we are looping we won't allocate more stack than necessary. Suggested by wesommer@mit.edu (Bill Sommerfeld). --- libihash/ChangeLog | 7 +++++++ libihash/primes.c | 6 ++---- 2 files changed, 9 insertions(+), 4 deletions(-) (limited to 'libihash') diff --git a/libihash/ChangeLog b/libihash/ChangeLog index 62f056e9..000d60a6 100644 --- a/libihash/ChangeLog +++ b/libihash/ChangeLog @@ -1,3 +1,10 @@ +Fri Mar 5 17:13:04 1999 Thomas Bushnell, BSG + + * primes.c (_ihash_nextprime): Use a dynamically-sized array for + `seive' instead of alloca, so that if we are looping we won't + allocate more stack than necessary. Suggested by wesommer@mit.edu + (Bill Sommerfeld). + 1997-06-20 Miles Bader * ihash.c (ihash_create): Initialize CLEANUP & CLEANUP_ARG fields. diff --git a/libihash/primes.c b/libihash/primes.c index 3abc6f9d..c67b66fb 100644 --- a/libihash/primes.c +++ b/libihash/primes.c @@ -1,5 +1,5 @@ /* Prime number generation - Copyright (C) 1994, 1996 Free Software Foundation + Copyright (C) 1994, 1996, 1999 Free Software Foundation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as @@ -72,11 +72,9 @@ _ihash_nextprime (unsigned n) max_prime + 1 to 2 * max_prime, looking for more primes. */ unsigned start = next_sieve; unsigned end = start + max_prime + 1; - char *sieve = (char *) alloca ((end - start) * sizeof (*sieve)); + char sieve[end - start]; int i; - assert (sieve); - bzero (sieve, (end - start) * sizeof (*sieve)); /* Make the sieve indexed by prime number, rather than -- cgit v1.2.3