emacs-devel
[Top][All Lists]
Advanced

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

Re: Set operations on bool-vectors


From: Andreas Schwab
Subject: Re: Set operations on bool-vectors
Date: Sat, 21 Sep 2013 09:36:11 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux)

Daniel Colascione <address@hidden> writes:

> +static
> +ptrdiff_t
> +bool_vector_payload_bytes (EMACS_INT length)
> +{
> +  EMACS_INT exact_needed_bytes;
> +  EMACS_INT needed_bytes;
> +
> +  exact_needed_bytes = (length + CHAR_BIT - 1) / CHAR_BIT;
> +  needed_bytes =  (exact_needed_bytes + sizeof (size_t) - 1)
> +    / sizeof (size_t);
> +
> +  needed_bytes *= sizeof (size_t);

Please check for overflow.  Also, the return type should be EMACS_INT,
not ptrdiff_t.

Andreas.

-- 
Andreas Schwab, address@hidden
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."



reply via email to

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