[OT] C pointers: BSD versus Linux?
walt
wa1ter at myrealbox.com
Thu Jun 1 08:21:28 PDT 2006
Simon 'corecode' Schubert wrote:
> On 31.05.2006, at 20:37, jwatson at xxxxxxxxxxxx wrote:
>>> Style 1:
>>> time_t t*;
>>> time(t);
[...]
>> Also, style 1 is technically "incorrect" since you never allocated the
>> memory that t is pointing to before passing it into time().
> maybe the compiler on BSD by chance put NULL into "t" and thus made it a
> valid parameter?
First, thanks to all who replied! I've been playing with gdb and I'm
seeing a significant difference between linux and *BSD.
I added a dummy variable to my program, like this:
time_t t*, d;
and then ran the program in gdb. I printed out t and &d and
compared the two values under *BSD and linux.
What I see in linux is that the two values are miles apart,
but in *BSD they differ by only a few bytes. I *assume* this
means that in *BSD, t is pointing to a valid memory location
very close to d, whereas in linux t is pointing to some
random number. Does this seem a reasonable idea?
Thanks again for everyone's help.
More information about the Users
mailing list