malloc() behavior (was: Pointer please)
James Jacobsen
james_jacobsen at lycos.co.uk
Sun Oct 5 22:39:07 PDT 2003
You learn something new every day(probably not how to spell). I'm not
a very experienced programmer. I actual did not know about those
debugging tools. Thanks. :)
--James
On 10/05/03 22:31:09, Dan Nelson wrote:
> In the last episode (Oct 05), James Jacobsen said:
> > On 10/05/03 21:42:23, Robert Huff wrote:
> > >James Jacobsen writes:
> > >> It does not matter what freebsd does, C does not require that
> > >> malloc initialize space according to Kernighan and Ritchie.
> > >
> > >I knew that, and agree depending on a particular behavior is bad
> > >programming practice. That said, there's a lot of "bad
> programmers"
> > >out there ....
> >
> > What's really bad, is that freebsd could potentally change there
> > behavor down the line. Its probably dictated by the way kernel
> > dezined, meaning they may do whats the cheapist. I would. If they
> > do its go to lead to some weird behavior. :-)
>
> There's nothing bad about it. FreeBSD follows the standards. The
> debugging flags simply change what the undefined behaviour is. If
> you
> malloc a block of memory, you cannot rely on what data it currently
> contains. FreeBSD lets you zero it, fill it with a set value, or
> leave
> it.
>
> Programs exhibiting weird behaviour under any of those three cases
> are
> broken. Most debugging mallocs will trigger it, purify will probably
> catch it (never used it), and valgrind under Linux will definitely
> catch it.
>
> --
> Dan Nelson
> dnelson at allantgroup.com
> _______________________________________________
> freebsd-questions at freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-questions
> To unsubscribe, send any mail to "freebsd-questions-
> unsubscribe at freebsd.org"
>
>
More information about the freebsd-questions
mailing list