[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: NULL pointers.

From: Jack Repenning <jrepenning_at_collab.net>
Date: 2003-10-14 03:11:08 CEST

At 6:33 PM -0400 10/13/03, Paul Smith wrote:
>%% Greg Hudson <ghudson@MIT.EDU> writes:
>
> gh> I brought this up in October 2000 and lost then; don't expect to win any
> gh> time soon. :)
>
> gh> http://subversion.tigris.org/servlets/ReadMsg?list=dev&msgId=152209
>
>If you're really into solving this sort of problem, there's a trick I've
>been using for a while that I believe the standard requires to work.
>
>It turns out the C standard requires that a variable with static storage
>duration that is not explicitly initialized will be initialized by the
>compiler such that all integral values are set to 0 and all pointer
>values are set to the null pointer constant.
>
>It further turns out the standard says that for any initializer which
>does not provide enough elements to initialize the entire aggregate, the
>remaining elements shall be initialized using the same rules as if they
>had static storage duration.
>
>
>Sooooo, a simple way of being sure that your memory is initialized
>properly, even on systems where a null pointer constant is not
>all-zero-bits, is this:
>
> struct some_complex_struct *foo
>
> {
> struct some_complex_struct __tmp = { 0 };

Doesn't this fail for the case where the _first_ field of
some_complex_struct is a pointer, and the local architecture does
something inane with NULL?

-- 
-==-
Jack Repenning
CollabNet, Inc.
8000 Marina Boulevard, Suite 600
Brisbane, California 94005
o: 650.228.2562
c: 408.835-8090
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Tue Oct 14 03:12:56 2003

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.