[vorbis] Use of const

Olaf van der Spek Olaf at XCC.TMFWeb.NL
Wed Jan 3 06:26:25 PST 2001



> Neither. initial could be const, but isn't. libvorbis doesn't make much
> (any?) use of the const keyword, though there are plenty of places it
would
> probably be good to use.

Because the source files are C and not C++, parameter types aren't checked,
so is the use of const really a good idea?

For example, this compiles fine (on VC++ 6), but itsn't right:

int ov_open(FILE *f,OggVorbis_File *vf,const char *initial,long ibytes){
  ov_callbacks callbacks = {
    (size_t (*)(void *, size_t, size_t, void *))  fread,
    (int (*)(void *, ogg_int64_t, int))              _fseek64_wrap,
    (int (*)(void *))                             fclose,
    (long (*)(void *))                            ftell
  };

  return ov_open_callbacks((void *)f, vf, initial, ibytes, callbacks);
}

int ov_open_callbacks(void *f,OggVorbis_File *vf,char *initial,long ibytes,
    ov_callbacks callbacks)
{
  long offset=(f?callbacks.seek_func(f,0,SEEK_CUR):-1);
  int ret;
 *initial = 0;

initial is passed as const in the first call, but then passed as non-const
in the call to ov_open_callbacks.

Olaf van der Spek
Almere, Holland
Olaf at XCC.TMFWeb.NL
http://xcc.tiberian.com/

--- >8 ----
List archives:  http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
To unsubscribe from this list, send a message to 'vorbis-request at xiph.org'
containing only the word 'unsubscribe' in the body.  No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.



More information about the Vorbis mailing list