Skip to content

Commit 9d1e0b8

Browse files
committed
ps_ptr pt22
1 parent 43c2dd6 commit 9d1e0b8

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

src/psram_unique_ptr.hpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -676,6 +676,14 @@ class ps_ptr {
676676
operator[](std::size_t index) const {
677677
return get()[index];
678678
}
679+
// —————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
680+
// 📌📌📌 R E L E A S E 📌📌📌
681+
T* release() {
682+
T* ptr = get(); // aktuellen Zeiger sichern
683+
mem.release(); // unique_ptr gibt den Zeiger frei und setzt sich auf nullptr
684+
allocated_size = 0; // optional: Größe zurücksetzen
685+
return ptr;
686+
}
679687
// —————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
680688
// 📌📌📌 M O V E 📌📌📌
681689

src/vorbis_decoder/vorbis_decoder.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1478,7 +1478,9 @@ vorbis_info_floor_t* floor1_info_unpack() {
14781478
ps_ptr<uint8_t> B;
14791479
int32_t j, k, count = 0, maxclass = -1, rangebits;
14801480

1481-
vorbis_info_floor_t *info = (vorbis_info_floor_t *)ps_calloc(1, sizeof(vorbis_info_floor_t));
1481+
ps_ptr<vorbis_info_floor_t> info;
1482+
info.alloc(sizeof(vorbis_info_floor_t));
1483+
info.clear();
14821484
/* read partitions */
14831485
info->partitions = bitReader(5); /* only 0 to 31 legal */
14841486
info->partitionclass.alloc(info->partitions * sizeof(uint8_t));
@@ -1583,10 +1585,10 @@ vorbis_info_floor_t* floor1_info_unpack() {
15831585
info->hineighbor[j] = hi;
15841586
}
15851587

1586-
return (info);
1588+
return (info.release());
15871589

15881590
err_out:
1589-
return (NULL);
1591+
return {};
15901592
}
15911593
//---------------------------------------------------------------------------------------------------------------------
15921594
/* vorbis_info is for range checking */

0 commit comments

Comments
 (0)