Re: What's in git.git

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

 




On Sun, 25 Jun 2006, Timo Hirvonen wrote:
> > 
> > I suspect that both could have been made to use NULL instead to indicate 
> > that no pointer exists.
> 
> I'll look into this.

An alternative is to really mark the char pointer structure members const. 
That is often the preferred thing to do, if usage allows it.

The biggest problem I've traditionally had with structure members that are 
"const char *" has ironically been that the standard C definition of 
"free()" is misdesigned. 

"free()" should take a "const volatile void *", not just a "void *". As it 
is, you often have to cast things to free() just to avoid the warning 
about discarding qualifiers. Which is really sad.

It's perfectly valid to do something like

	struct xyzzy {
		const char *member;
		..
	};

	s->member = strdup(string);
	..
	free(s->member);
	free(s)

but sadly, that member free generates a (bogus) warning.

Of course, we should probably do a "xfree()" anyway, to match our 
"x[c|re]alloc()".

			Linus
-
: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]