🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #1484

Re: SIZE_T_MAX (Re: More fwrite limits)

#1484
From: Karl Heuer
Date: Sun, 08 Jul 1990 20:01
9 lines
976 bytes
In article <Fq7k90?@cs.psu.edu> flee@guardian.cs.psu.edu (Felix Lee) writes:
>Here are some innocuous statements that can run into trouble...

To test whether (expr <= SIZE_T_MAX), where (expr) is unsigned long int, use
(expr == (unsigned long int)(size_t)expr).  In your example,
	unsigned long int sz = 1UL + strlen(a) + strlen(b);
	s = (sz != (unsigned long int)(size_t)sz ? NULL : malloc((size_t)sz));

Karl W. Z. Heuer (karl@kelp.ima.isc.com or ima!kelp!karl), The Walking Lint
Technical Details
Message-ID: <17043@haddock.ima.isc.com>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!watserv1!watmath!att!ima!haddock!karl
References: <3159@disk.UUCP> <25096@mimsy.umd.edu> <Fw?ycgy@cs.psu.edu> <13284@smoke.BRL.MIL> <Fq7k90?@cs.psu.edu>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!watserv1!watmath!att!ima!haddock!karl
From: karl@haddock.ima.isc.com (Karl Heuer)
Newsgroups: comp.std.c
Subject: Re: SIZE_T_MAX (Re: More fwrite limits)
Message-ID: <17043@haddock.ima.isc.com>
Date: 8 Jul 90 20:01:05 GMT
References: <3159@disk.UUCP> <25096@mimsy.umd.edu> <Fw?ycgy@cs.psu.edu> <13284@smoke.BRL.MIL> <Fq7k90?@cs.psu.edu>
Reply-To: karl@haddock.ima.isc.com (Karl Heuer)
Organization: Interactive Systems, Cambridge, MA 02138-5302
Lines: 9