Date: Thu, 17 Apr 2003 08:08:03 -0500 From: "Jacques A. Vidrine" <nectar@FreeBSD.org> To: Munechika Sumikawa <sumikawa@ebina.hitachi.co.jp> Cc: src-committers@FreeBSD.org Subject: Re: cvs commit: src/lib/libipsec pfkey_dump.c Message-ID: <20030417130803.GA99068@madman.celabo.org> In-Reply-To: <20030417.082357.81502723.sumikawa@ebina.hitachi.co.jp> References: <200304161121.h3GBLDhJ040405@repoman.freebsd.org> <20030416124657.GD72501@madman.celabo.org> <20030417.082357.81502723.sumikawa@ebina.hitachi.co.jp>
next in thread | previous in thread | raw e-mail | index | archive | help
On Thu, Apr 17, 2003 at 08:23:57AM +0000, Munechika Sumikawa wrote: > nectar> These sizes seem arbitrary. Previously, at 10 bytes, they were just a > nectar> bit too small to hold the representation of the largest 32-bit > nectar> unsigned integer. Now at 20 bytes, they are just a bit too small to > nectar> hold the representation of the largest 64-bit unsigned integer. This > nectar> seems sloppy. (As does using a 128 byte buffer to hold the result of > nectar> concatenating two 20 byte buffers.) > > You are right. I've changed to 128 bytes. Er, that wasn't quite my point :-) My point was that the buffer should be sized correctly (rather than fudged), such as char prefbuf[] = "/4294967296"; /* OR */ char prebuf[12]; or whatever you expect the maximum integer to be. [Isn't this a network prefix? Surely 3 digits is sufficient?] It just seems like a lot of wastage, but of course it isn't really important. > It can be used until we > support 512bit CPU :-) Actually 128 bytes is just big enough to hold a NUL-terminated string representation of a 421-bit unsigned integer. You need 156 bytes for 512 bits :-) Also, these two 128 byte buffers are still being concatenated into a single 128 byte buffer, so on average you have room for about 209 bits :-) Cheers, -- Jacques A. Vidrine <nectar@celabo.org> http://www.celabo.org/ NTT/Verio SME . FreeBSD UNIX . Heimdal Kerberos jvidrine@verio.net . nectar@FreeBSD.org . nectar@kth.se
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20030417130803.GA99068>