[Vorbis-dev] Add vorbis_dsp_init() ?

Gregory Maxwell gmaxwell at gmail.com
Sun Mar 15 11:43:11 PDT 2009


On Sun, Mar 15, 2009 at 10:44 AM, ogg.k.ogg.k at googlemail.com
<ogg.k.ogg.k at googlemail.com> wrote:
>> Is a memset of zeros also promised to create proper null pointers just
>> as assigning with zero?  (The value in memory for a null pointer isn't
>> guarenteed to be the all zero bit sequence)
>
> Pedantically, I think not (though I'm very hazy with the distinction
> of the null pointer and its bit pattern that can be non zeros).
> Are you aware of an implementation that does this ? I do recall
> eerie discussions about assigments of a pointer with 0 yielding
> this non zero bit pattern, but that was years ago.
>
> Moreover, I'm entirely in the dark what would then happen to:
>
> void foo(char *p)
> {
>  if (p) *p=0;
> }
>
> Would the test of p test against the null pointer, or cast p to an
> int, then test this int ?


There is zero ambiguity: If(pointer) is testing nullness. *pointer=0
makes the pointer null (even if the null pointer is not zero). These
are special cases explicitly addressed in the standard. :)

There are real platforms today (oddball small embedded things) where
the null pointer is not 0.  I doubt anyone is using Vorbis on any of
these and I wouldn't be surprised if libvorbis doesn't work on them,
but gratuitous incompatibilities should be avoided.

I asked because I wasn't sure if memsetting with zeros was some
additional exception case, but I'm pretty sure it's not, and I was
simply curious.

Since I've already spoken up, I might as well have my say on the color
of the shed...

The issue here is that you never call headerin on a file without
headers, then you later lose your mind since the headerin would have
initilized some things. Right?  Why not make it so headerin can be
called with a null packet, and make it the API rule that you always
call headerin?  (I ask more to satisfy my own limited understanding of
the vorbisfile API then to suggest that the change is wrong…)


More information about the Vorbis-dev mailing list