From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Andreas Schwab Newsgroups: gmane.emacs.devel Subject: Re: Set operations on bool-vectors Date: Sat, 21 Sep 2013 09:36:11 +0200 Message-ID: <87a9j6bp90.fsf@igel.home> References: <523CD363.6020400@dancol.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1379748994 20838 80.91.229.3 (21 Sep 2013 07:36:34 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 21 Sep 2013 07:36:34 +0000 (UTC) Cc: Emacs development discussions To: Daniel Colascione Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Sep 21 09:36:36 2013 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1VNHk2-00043e-OG for ged-emacs-devel@m.gmane.org; Sat, 21 Sep 2013 09:36:34 +0200 Original-Received: from localhost ([::1]:58858 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VNHk2-0005iH-8F for ged-emacs-devel@m.gmane.org; Sat, 21 Sep 2013 03:36:34 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:58427) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VNHju-0005iA-2p for emacs-devel@gnu.org; Sat, 21 Sep 2013 03:36:32 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VNHjo-0004ea-EQ for emacs-devel@gnu.org; Sat, 21 Sep 2013 03:36:26 -0400 Original-Received: from mail-out.m-online.net ([212.18.0.10]:49120) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VNHjo-0004ct-8M for emacs-devel@gnu.org; Sat, 21 Sep 2013 03:36:20 -0400 Original-Received: from frontend1.mail.m-online.net (frontend1.mail.intern.m-online.net [192.168.8.180]) by mail-out.m-online.net (Postfix) with ESMTP id 3chkB91MLFz3hhTj; Sat, 21 Sep 2013 09:36:16 +0200 (CEST) Original-Received: from localhost (dynscan1.mnet-online.de [192.168.6.68]) by mail.m-online.net (Postfix) with ESMTP id 3chkB845NPzbbcY; Sat, 21 Sep 2013 09:36:16 +0200 (CEST) X-Virus-Scanned: amavisd-new at mnet-online.de Original-Received: from mail.mnet-online.de ([192.168.8.180]) by localhost (dynscan1.mail.m-online.net [192.168.6.68]) (amavisd-new, port 10024) with ESMTP id PY_SbQA5H02O; Sat, 21 Sep 2013 09:36:12 +0200 (CEST) X-Auth-Info: +BJZElKiGgSHze699gd+y4So5N3YLuRsq1K6gOUnU8Y= Original-Received: from igel.home (ppp-88-217-116-101.dynamic.mnet-online.de [88.217.116.101]) by mail.mnet-online.de (Postfix) with ESMTPA; Sat, 21 Sep 2013 09:36:12 +0200 (CEST) Original-Received: by igel.home (Postfix, from userid 1000) id 00BE52C02BD; Sat, 21 Sep 2013 09:36:11 +0200 (CEST) X-Yow: Hey, waiter! I want a NEW SHIRT and a PONY TAIL with lemon sauce! In-Reply-To: <523CD363.6020400@dancol.org> (Daniel Colascione's message of "Fri, 20 Sep 2013 15:59:47 -0700") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x X-Received-From: 212.18.0.10 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:163528 Archived-At: Daniel Colascione 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, schwab@linux-m68k.org GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5 "And now for something completely different."