Skip to content

Commit 1456339

Browse files
committed
ps_ptr pt15
1 parent b536dec commit 1456339

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

src/vorbis_decoder/vorbis_decoder.cpp

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -819,7 +819,7 @@ int32_t VORBISFindSyncWord(unsigned char *buf, int32_t nBytes){
819819
}
820820
//---------------------------------------------------------------------------------------------------------------------
821821
int32_t vorbis_book_unpack(codebook_t *s) {
822-
char *lengthlist = NULL;
822+
ps_ptr<char> lengthlist;
823823
uint8_t quantvals = 0;
824824
int32_t i, j;
825825
int32_t maptype;
@@ -845,7 +845,7 @@ int32_t vorbis_book_unpack(codebook_t *s) {
845845
switch(bitReader(1)) {
846846
case 0:
847847
/* unordered */
848-
lengthlist = (char *)ps_malloc(sizeof(char) * s->entries);
848+
lengthlist.alloc(sizeof(char) * s->entries);
849849

850850
/* allocated but unused entries? */
851851
if(bitReader(1)) {
@@ -881,7 +881,7 @@ int32_t vorbis_book_unpack(codebook_t *s) {
881881
int32_t length = bitReader(5) + 1;
882882

883883
s->used_entries = s->entries;
884-
lengthlist = (char *)ps_malloc(sizeof(char) * s->entries);
884+
lengthlist.alloc(sizeof(char) * s->entries);
885885

886886
for(i = 0; i < s->entries;) {
887887
int32_t num = bitReader(_ilog(s->entries - i));
@@ -917,7 +917,7 @@ int32_t vorbis_book_unpack(codebook_t *s) {
917917
s->dec_nodeb = _determine_node_bytes(s->used_entries, _ilog(s->entries) / 8 + 1);
918918
s->dec_leafw = _determine_leaf_words(s->dec_nodeb, _ilog(s->entries) / 8 + 1);
919919
s->dec_type = 0;
920-
ret = _make_decode_table(s, lengthlist, quantvals, maptype);
920+
ret = _make_decode_table(s, lengthlist.get(), quantvals, maptype);
921921
if(ret != 0) {
922922
goto _errout;
923923
}
@@ -947,7 +947,7 @@ int32_t vorbis_book_unpack(codebook_t *s) {
947947
s->dec_type = 1;
948948
s->dec_nodeb = _determine_node_bytes(s->used_entries, (s->q_bits * s->dim + 8) / 8);
949949
s->dec_leafw = _determine_leaf_words(s->dec_nodeb, (s->q_bits * s->dim + 8) / 8);
950-
ret = _make_decode_table(s, lengthlist, quantvals, maptype);
950+
ret = _make_decode_table(s, lengthlist.get(), quantvals, maptype);
951951
if(ret) {
952952
goto _errout;
953953
}
@@ -971,7 +971,7 @@ int32_t vorbis_book_unpack(codebook_t *s) {
971971
s->dec_nodeb = _determine_node_bytes(s->used_entries, (_ilog(quantvals - 1) * s->dim + 8) / 8);
972972
s->dec_leafw = _determine_leaf_words(s->dec_nodeb, (_ilog(quantvals - 1) * s->dim + 8) / 8);
973973

974-
ret = _make_decode_table(s, lengthlist, quantvals, maptype);
974+
ret = _make_decode_table(s, lengthlist.get(), quantvals, maptype);
975975
if(ret){
976976
goto _errout;
977977
}
@@ -989,15 +989,15 @@ int32_t vorbis_book_unpack(codebook_t *s) {
989989
s->dec_type = 1;
990990
s->dec_nodeb = _determine_node_bytes(s->used_entries, (s->q_bits * s->dim + 8) / 8);
991991
s->dec_leafw = _determine_leaf_words(s->dec_nodeb, (s->q_bits * s->dim + 8) / 8);
992-
if(_make_decode_table(s, lengthlist, quantvals, maptype)) goto _errout;
992+
if(_make_decode_table(s, lengthlist.get(), quantvals, maptype)) goto _errout;
993993
}
994994
else {
995995
/* use dec_type 3: scalar offset into packed value array */
996996

997997
s->dec_type = 3;
998998
s->dec_nodeb = _determine_node_bytes(s->used_entries, _ilog(s->used_entries - 1) / 8 + 1);
999999
s->dec_leafw = _determine_leaf_words(s->dec_nodeb, _ilog(s->used_entries - 1) / 8 + 1);
1000-
if(_make_decode_table(s, lengthlist, quantvals, maptype)) goto _errout;
1000+
if(_make_decode_table(s, lengthlist.get(), quantvals, maptype)) goto _errout;
10011001

10021002
/* get the vals & pack them */
10031003
s->q_pack = (s->q_bits + 7) / 8 * s->dim;
@@ -1018,11 +1018,9 @@ int32_t vorbis_book_unpack(codebook_t *s) {
10181018
goto _errout;
10191019
}
10201020
if(oggpack_eop()) goto _eofout;
1021-
if(lengthlist) {free(lengthlist); lengthlist = NULL;}
10221021
return 0; // ok
10231022
_errout:
10241023
_eofout:
1025-
if(lengthlist) {free(lengthlist); lengthlist = NULL;}
10261024
return -1; // error
10271025
}
10281026
//---------------------------------------------------------------------------------------------------------------------

0 commit comments

Comments
 (0)