Re: checking status of GString
- From: Owen Taylor <otaylor redhat com>
- To: Federico Mena Quintero <federico redhat com>
- Cc: gtk-list redhat com
- Subject: Re: checking status of GString
- Date: 30 Nov 1999 11:41:30 -0500
Federico Mena Quintero <federico@redhat.com> writes:
> > [ Actually, assumming that NULL will have a bit-pattern of
> > all zeros is not standard ANSI C, though it works
> > universally on the platforms where GTK+ runs. ]
>
> This is a runtime issue, not a compile-time issue. The compiler must
> spit code to mangle zeros-in-pointers to whatever null pointer
> representation the machine uses. Otherwise
>
> int i = 0;
> void *foo;
>
> foo = i;
>
> wouldn't work. Whether it is good practice to use such code is a
> completely different issue :-)
But, only in assignments of integers to pointers.
A compiler is allowed (at the penalty of breaking tons of code) to
write, for foo = i,
if (i == 0)
foo = SPECIAL_NULL_BIT_PATTERN;
else
/* skip the assignment */;
So, this is not the same case as:
MyStruct *foo = g_new0 (MyStrict, 1);
if (foo->pointer != NULL)
g_free (foo->pointer);
Which isn't guaranteed to work. But does anyways on almost
any platform.
Anyways, enough language-lawyering for the day.
Owen
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]