guile-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Uniform vector lengths -- how long?


From: Rob Browning
Subject: Re: Uniform vector lengths -- how long?
Date: Mon, 12 Jul 2004 10:04:05 -0500
User-agent: Gnus/5.1006 (Gnus v5.10.6) Emacs/21.3 (gnu/linux)

Kevin Ryde <address@hidden> writes:

> I suppose, though personally I wouldn't feel any great urgency for
> that.  A positive inum ends up only, what, 3 bits less than a ulong,
> and a 512Mb array would be more than likely bigger than one could do
> real work with on a 32-bit machine.
>
> What is worth worrying about though would be making sure the "len *
> uvec_sizes[type]" in make_uvec doesn't overflow, perhaps wrapping
> around to a small size which is successfully malloced.  I guess
> currently with a maximum 8 in uvec_sizes and maximum
> MOST_POSITIVE_INUM for the count it's ok.

OK, I've fixed both of these.  After talking to Marius, I reworked
srfi-4 to use size_t for the length, since (as he pointed out) that's
what you'll eventually pass to malloc, and we will just make the
assertion that size_t must fit in a cell.

I also added checking to make_uvec to avoid the possibility of
overflow with types bigger than 1 byte.  Although the current solution
depends on SIZE_MAX being defined, and we wondered if it's
sufficiently common.

  if (len > ((size_t) SIZE_MAX / uvec_sizes[type])) ...

(I'll commit after I have a chance to double check the work.)

Thanks
-- 
Rob Browning
rlb @defaultvalue.org and @debian.org; previously @cs.utexas.edu
GPG starting 2002-11-03 = 14DD 432F AE39 534D B592  F9A0 25C8 D377 8C7E 73A4




reply via email to

[Prev in Thread] Current Thread [Next in Thread]