- for(i=0;i<vi->modes;i++)
- if(vi->mode_param[i])free(vi->mode_param[i]);
- /*if(vi->mode_param)free(vi->mode_param);*/
-
- for(i=0;i<vi->maps;i++) /* unpack does the range checking */
- _mapping_P[vi->map_type[i]]->free_info(vi->map_param[i]);
- /*if(vi->map_param)free(vi->map_param);*/
-
- for(i=0;i<vi->times;i++) /* unpack does the range checking */
- _time_P[vi->time_type[i]]->free_info(vi->time_param[i]);
- /*if(vi->time_param)free(vi->time_param);*/
-
- for(i=0;i<vi->floors;i++) /* unpack does the range checking */
- _floor_P[vi->floor_type[i]]->free_info(vi->floor_param[i]);
- /*if(vi->floor_param)free(vi->floor_param);*/
-
- for(i=0;i<vi->residues;i++) /* unpack does the range checking */
- _residue_P[vi->residue_type[i]]->free_info(vi->residue_param[i]);
- /*if(vi->residue_param)free(vi->residue_param);*/
-
- /* the static codebooks *are* freed if you call info_clear, because
- decode side does alloc a 'static' codebook. Calling clear on the
- full codebook does not clear the static codebook (that's our
- responsibility) */
- for(i=0;i<vi->books;i++){
- /* just in case the decoder pre-cleared to save space */
- if(vi->book_param[i]){
- vorbis_staticbook_clear(vi->book_param[i]);
- free(vi->book_param[i]);
+ if(ci){
+
+ for(i=0;i<ci->modes;i++)
+ if(ci->mode_param[i])_ogg_free(ci->mode_param[i]);
+
+ for(i=0;i<ci->maps;i++) /* unpack does the range checking */
+ if(ci->map_param[i]) /* this may be cleaning up an aborted
+ unpack, in which case the below type
+ cannot be trusted */
+ _mapping_P[ci->map_type[i]]->free_info(ci->map_param[i]);
+
+ for(i=0;i<ci->floors;i++) /* unpack does the range checking */
+ if(ci->floor_param[i]) /* this may be cleaning up an aborted
+ unpack, in which case the below type
+ cannot be trusted */
+ _floor_P[ci->floor_type[i]]->free_info(ci->floor_param[i]);
+
+ for(i=0;i<ci->residues;i++) /* unpack does the range checking */
+ if(ci->residue_param[i]) /* this may be cleaning up an aborted
+ unpack, in which case the below type
+ cannot be trusted */
+ _residue_P[ci->residue_type[i]]->free_info(ci->residue_param[i]);
+
+ for(i=0;i<ci->books;i++){
+ if(ci->book_param[i]){
+ /* knows if the book was not alloced */
+ vorbis_staticbook_destroy(ci->book_param[i]);
+ }
+ if(ci->fullbooks)
+ vorbis_book_clear(ci->fullbooks+i);