Skip to content

Commit 9405a3d

Browse files
committed
WIP CSkinnedModel
1 parent 484417b commit 9405a3d

File tree

11 files changed

+478
-52
lines changed

11 files changed

+478
-52
lines changed

config/GM8E01_00/symbols.txt

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -14820,21 +14820,21 @@ Initialize__14CGameAllocatorFR10COsContext = .text:0x803521BC; // type:function
1482014820
__dt__14CGameAllocatorFv = .text:0x80352544; // type:function size:0x88 scope:global
1482114821
__ct__14CGameAllocatorFv = .text:0x803525CC; // type:function size:0x94 scope:global
1482214822
GetMemInfoFromBlockPtr__14CGameAllocatorCFPCv = .text:0x80352660; // type:function size:0x8 scope:global
14823-
fn_80352668 = .text:0x80352668; // type:function size:0xA0
14823+
AllocateNewWorkspace__13CSkinnedModelFPPf = .text:0x80352668; // type:function size:0xA0 scope:global
1482414824
ClearPointGeneratorFunc__13CSkinnedModelFv = .text:0x80352708; // type:function size:0xC scope:global
1482514825
SetPointGeneratorFunc__13CSkinnedModelFPvPFPvPC9CVector3fPC9CVector3fi_v = .text:0x80352714; // type:function size:0xC scope:global
1482614826
RemoveDummySkinnedModelRef__13CSkinnedModelFv = .text:0x80352720; // type:function size:0x20
14827-
fn_80352740 = .text:0x80352740; // type:function size:0x20
14828-
fn_80352760 = .text:0x80352760; // type:function size:0x10C
14827+
AddDummySkinnedModelRef__13CSkinnedModelFv = .text:0x80352740; // type:function size:0x20
14828+
PostDrawFunc__13CSkinnedModelCFv = .text:0x80352760; // type:function size:0x10C
1482914829
AllocateStorage__13CSkinnedModelFv = .text:0x8035286C; // type:function size:0x180 scope:global
1483014830
EnsureAllocation__13CSkinnedModelFi = .text:0x803529EC; // type:function size:0x184 scope:global
1483114831
TickAllocations__13CSkinnedModelFv = .text:0x80352B70; // type:function size:0xA8 scope:global
1483214832
CalculateDefault__13CSkinnedModelFv = .text:0x80352C18; // type:function size:0xE0 scope:global
1483314833
Calculate__13CSkinnedModelFRC17CPoseAsTransformsRCQ24rstl37optional_object<18CVertexMorphEffect>PCfPf = .text:0x80352CF8; // type:function size:0x1F0 scope:global
14834-
fn_80352EE8 = .text:0x80352EE8; // type:function size:0x38
14835-
DoDrawCallback__13CSkinnedModelF14FCustomDrawCPv = .text:0x80352F20; // type:function size:0x144 scope:global
14836-
fn_80353064 = .text:0x80353064; // type:function size:0xBC
14837-
fn_80353120 = .text:0x80353120; // type:function size:0x15C
14834+
Draw__13CSkinnedModelCFPCfPCfRC11CModelFlags = .text:0x80352EE8; // type:function size:0x38 scope:global
14835+
DoDrawCallback__13CSkinnedModelFPFPCfPCfPCv_vPv = .text:0x80352F20; // type:function size:0x144 scope:global
14836+
Draw__13CSkinnedModelCFRC11CModelFlags = .text:0x80353064; // type:function size:0xBC scope:global
14837+
Construct__13CSkinnedModelFv = .text:0x80353120; // type:function size:0x15C
1483814838
__dt__13CSkinnedModelFv = .text:0x8035327C; // type:function size:0xE8 scope:global
1483914839
__ct__13CSkinnedModelFRC13CSkinnedModel = .text:0x80353364; // type:function size:0xD4 scope:global
1484014840
__ct__13CSkinnedModelFRC21TLockedToken<6CModel>RC26TLockedToken<10CSkinRules>RC31TLockedToken<15CCharLayoutInfo>Q213CSkinnedModel14EDataOwnership = .text:0x80353438; // type:function size:0xD4 scope:global
@@ -14848,7 +14848,7 @@ ProcessingNormals__10CSkinRulesFiPPUs = .text:0x803538F4; // type:function size:
1484814848
ProcessingPoints__10CSkinRulesFiPPUs = .text:0x803539F0; // type:function size:0xFC scope:global
1484914849
WaitForQueue__Fv = .text:0x80353AEC; // type:function size:0x30 scope:global
1485014850
StartNextTransaction__10CSkinRulesFv = .text:0x80353B1C; // type:function size:0xF8 scope:global
14851-
InitLockedCacheState__10CSkinRulesFRC10CSkinRules = .text:0x80353C14; // type:function size:0x50 scope:global
14851+
InitLockedCacheState__10CSkinRulesFRC6CModel = .text:0x80353C14; // type:function size:0x50 scope:global
1485214852
FSkinRulesFactory__FRC10SObjectTagR12CInputStreamRC15CVParamTransfer = .text:0x80353C64; // type:function size:0xE0 scope:global
1485314853
__dt__20TToken<10CSkinRules>Fv = .text:0x80353D44; // type:function size:0x90 scope:global
1485414854
GetIObjObjectFor__20TToken<10CSkinRules>FRCQ24rstl22auto_ptr<10CSkinRules> = .text:0x80353DD4; // type:function size:0x2C scope:global
@@ -14936,17 +14936,17 @@ Reset__18CVertexMorphEffectFRC13CUnitVector3fRC9CVector3ff = .text:0x803574E0; /
1493614936
MorphVertices__18CVertexMorphEffectCFP9CVector3fPC9CVector3fRC26TLockedToken<10CSkinRules>RC17CPoseAsTransformsUi = .text:0x80357598; // type:function size:0x3D4 scope:global
1493714937
Update__18CVertexMorphEffectFf = .text:0x8035796C; // type:function size:0x38 scope:global
1493814938
__ct__27CSkinnedModelWithAvgNormalsFRC13CSkinnedModel = .text:0x803579A4; // type:function size:0x35C scope:global
14939-
fn_80357D00 = .text:0x80357D00; // type:function size:0x7C
14940-
fn_80357D7C = .text:0x80357D7C; // type:function size:0x28
14941-
fn_80357DA4 = .text:0x80357DA4; // type:function size:0x54
14942-
fn_80357DF8 = .text:0x80357DF8; // type:function size:0x98
14943-
fn_80357E90 = .text:0x80357E90; // type:function size:0xB4
14944-
fn_80357F44 = .text:0x80357F44; // type:function size:0x8C
14945-
fn_80357FD0 = .text:0x80357FD0; // type:function size:0x50
14946-
fn_80358020 = .text:0x80358020; // type:function size:0x7C
14947-
fn_8035809C = .text:0x8035809C; // type:function size:0x78
14939+
push_back__Q24rstl105vector<Q24rstl61pair<9CVector3f,Q24rstl35list<Ui,Q24rstl17rmemory_allocator>>,Q24rstl17rmemory_allocator>FRCQ24rstl61pair<9CVector3f,Q24rstl35list<Ui,Q24rstl17rmemory_allocator>> = .text:0x80357D00; // type:function size:0x7C scope:weak
14940+
construct<Q24rstl61pair<9CVector3f,Q24rstl35list<Ui,Q24rstl17rmemory_allocator>>>__4rstlFPvRCQ24rstl61pair<9CVector3f,Q24rstl35list<Ui,Q24rstl17rmemory_allocator>> = .text:0x80357D7C; // type:function size:0x28
14941+
__ct__Q24rstl61pair<9CVector3f,Q24rstl35list<Ui,Q24rstl17rmemory_allocator>>FRCQ24rstl61pair<9CVector3f,Q24rstl35list<Ui,Q24rstl17rmemory_allocator>> = .text:0x80357DA4; // type:function size:0x54 scope:weak
14942+
__ct__Q24rstl35list<Ui,Q24rstl17rmemory_allocator>FRCQ24rstl35list<Ui,Q24rstl17rmemory_allocator> = .text:0x80357DF8; // type:function size:0x98 scope:weak
14943+
insert<Q34rstl35list<Ui,Q24rstl17rmemory_allocator>14const_iterator>__Q24rstl35list<Ui,Q24rstl17rmemory_allocator>FRCQ34rstl35list<Ui,Q24rstl17rmemory_allocator>8iteratorQ34rstl35list<Ui,Q24rstl17rmemory_allocator>14const_iteratorQ34rstl35list<Ui,Q24rstl17rmemory_allocator>14const_iterator = .text:0x80357E90; // type:function size:0xB4
14944+
__dt__Q34rstl35list<Ui,Q24rstl17rmemory_allocator>14destroy_helperFv = .text:0x80357F44; // type:function size:0x8C scope:weak
14945+
__ct__Q24rstl61pair<9CVector3f,Q24rstl35list<Ui,Q24rstl17rmemory_allocator>>FRC9CVector3fRCQ24rstl35list<Ui,Q24rstl17rmemory_allocator> = .text:0x80357FD0; // type:function size:0x50 scope:weak
14946+
do_erase__Q24rstl35list<Ui,Q24rstl17rmemory_allocator>FPQ34rstl35list<Ui,Q24rstl17rmemory_allocator>4node = .text:0x80358020; // type:function size:0x7C scope:weak
14947+
__dt__Q24rstl35list<Ui,Q24rstl17rmemory_allocator>Fv = .text:0x8035809C; // type:function size:0x78 scope:weak
1494814948
reserve__Q24rstl105vector<Q24rstl61pair<9CVector3f,Q24rstl35list<Ui,Q24rstl17rmemory_allocator>>,Q24rstl17rmemory_allocator>Fi = .text:0x80358114; // type:function size:0xE0 scope:global
14949-
fn_803581F4 = .text:0x803581F4; // type:function size:0x68
14949+
uninitialized_copy<Q24rstl231pointer_iterator<Q24rstl61pair<9CVector3f,Q24rstl35list<Ui,Q24rstl17rmemory_allocator>>,Q24rstl105vector<Q24rstl61pair<9CVector3f,Q24rstl35list<Ui,Q24rstl17rmemory_allocator>>,Q24rstl17rmemory_allocator>,Q24rstl17rmemory_allocator>,PQ24rstl61pair<9CVector3f,Q24rstl35list<Ui,Q24rstl17rmemory_allocator>>>__4rstlFQ24rstl231pointer_iterator<Q24rstl61pair<9CVector3f,Q24rstl35list<Ui,Q24rstl17rmemory_allocator>>,Q24rstl105vector<Q24rstl61pair<9CVector3f,Q24rstl35list<Ui,Q24rstl17rmemory_allocator>>,Q24rstl17rmemory_allocator>,Q24rstl17rmemory_allocator>Q24rstl231pointer_iterator<Q24rstl61pair<9CVector3f,Q24rstl35list<Ui,Q24rstl17rmemory_allocator>>,Q24rstl105vector<Q24rstl61pair<9CVector3f,Q24rstl35list<Ui,Q24rstl17rmemory_allocator>>,Q24rstl17rmemory_allocator>,Q24rstl17rmemory_allocator>PQ24rstl61pair<9CVector3f,Q24rstl35list<Ui,Q24rstl17rmemory_allocator>> = .text:0x803581F4; // type:function size:0x68
1495014950
__dt__13CTimeProviderFv = .text:0x8035825C; // type:function size:0x78 scope:global
1495114951
__ct__13CTimeProviderFRCf = .text:0x803582D4; // type:function size:0x60 scope:global
1495214952
GetMRAMSafe__10CARAMTokenFv = .text:0x80358334; // type:function size:0x54 scope:global
@@ -17860,7 +17860,7 @@ lbl_803D8220 = .rodata:0x803D8220; // type:object size:0x7 data:string
1786017860
@stringBase0 = .rodata:0x803D8230; // type:object size:0xD scope:local data:string_table
1786117861
lbl_803D8240 = .rodata:0x803D8240; // type:object size:0x7 data:string
1786217862
lbl_803D8248 = .rodata:0x803D8248; // type:object size:0xB0
17863-
lbl_803D82F8 = .rodata:0x803D82F8; // type:object size:0x7 data:string
17863+
@stringBase0 = .rodata:0x803D82F8; // type:object size:0x7 scope:local data:string_table
1786417864
lbl_803D8300 = .rodata:0x803D8300; // type:object size:0x7 data:string
1786517865
lbl_803D8308 = .rodata:0x803D8308; // type:object size:0x7 data:string
1786617866
skInvalidString = .rodata:0x803D8310; // type:object size:0x10 scope:local data:wstring
@@ -22195,12 +22195,12 @@ lbl_805A95E4 = .sbss:0x805A95E4; // type:object size:0x4 data:4byte
2219522195
lbl_805A95E8 = .sbss:0x805A95E8; // type:object size:0x1 data:byte
2219622196
lbl_805A95E9 = .sbss:0x805A95E9; // type:object size:0x1 data:byte
2219722197
lbl_805A95EA = .sbss:0x805A95EA; // type:object size:0x6 data:byte
22198-
lbl_805A95F0 = .sbss:0x805A95F0; // type:object size:0x4 data:4byte
22199-
lbl_805A95F4 = .sbss:0x805A95F4; // type:object size:0x4 data:4byte
22198+
sPointGen__13CSkinnedModel = .sbss:0x805A95F0; // type:object size:0x4 scope:global data:4byte
22199+
sPointGenData__13CSkinnedModel = .sbss:0x805A95F4; // type:object size:0x4 scope:global data:4byte
2220022200
skCurrentToken__8Skinning = .sbss:0x805A95F8; // type:object size:0x2 data:2byte
2220122201
sNumSkinnedObjects__8Skinning = .sbss:0x805A95FC; // type:object size:0x4 data:4byte
2220222202
sSkinningInitialized__8Skinning = .sbss:0x805A9600; // type:object size:0x1 data:byte
22203-
lbl_805A9601 = .sbss:0x805A9601; // type:object size:0x7 data:byte
22203+
sbDumpedSpinLockMessage__8Skinning = .sbss:0x805A9601; // type:object size:0x1 scope:local data:byte
2220422204
lbl_805A9608 = .sbss:0x805A9608; // type:object size:0x1 data:byte
2220522205
lbl_805A960C = .sbss:0x805A960C; // type:object size:0x1 data:byte
2220622206
lbl_805A9610 = .sbss:0x805A9610; // type:object size:0x4 data:4byte

include/Kyoto/Animation/CSkinRules.hpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,26 @@
33

44
#include "Kyoto/Animation/CVirtualBone.hpp"
55

6+
class CCharLayoutInfo;
67
class CInputStream;
8+
class CModel;
9+
class CPoseAsTransforms;
10+
711
class CSkinRules {
812
public:
913
CSkinRules(CInputStream& in);
1014
~CSkinRules();
1115

16+
void InitLockedCacheState(const CModel& model);
17+
void BuildAccumulatedTransforms(const CPoseAsTransforms& pose,
18+
const CCharLayoutInfo& layoutInfo) const;
19+
void BuildPoints(volatile void* pipe) const;
20+
void BuildNormals(volatile void* pipe) const;
1221
void BuildNormalsFrom(const CVector3f* averageNormals, CVector3f* out) const;
1322
uint GetNumPoints() const { return x10_vertexCount; }
23+
uint GetNumNormals() const { return x14_normalCount; }
24+
int GetNumVirtualBones() const { return x0_virtualBones.size(); }
25+
const rstl::vector< CVirtualBone >& GetVirtualBones() const { return x0_virtualBones; }
1426

1527
private:
1628
rstl::vector< CVirtualBone > x0_virtualBones;

include/Kyoto/Animation/CSkinnedModel.hpp

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,21 @@
33

44
#include "types.h"
55

6+
#include "Kyoto/Animation/CSkinRules.hpp"
67
#include "Kyoto/TToken.hpp"
78

89
#include "rstl/auto_ptr.hpp"
910
#include "rstl/optional_object.hpp"
1011

1112
class CModel;
1213
class CModelFlags;
13-
class CSkinRules;
1414
class CCharLayoutInfo;
1515
class CPoseAsTransforms;
1616
class CVector3f;
1717
class CVertexMorphEffect;
1818

19+
typedef void (*TDrawFunc)(const float*, const float*, const void*);
20+
1921
class CSkinnedModel {
2022
public:
2123
enum EDataOwnership {
@@ -33,34 +35,49 @@ class CSkinnedModel {
3335
const TLockedToken< CCharLayoutInfo >& GetLayoutInfo() const { return x1c_layoutInfo; }
3436

3537
void CalculateDefault();
36-
int GetNumPoints() const;
38+
int GetNumPoints() const { return x10_skinRules->GetNumPoints(); }
3739
const CVector3f* GetPositions() const;
3840
void Calculate(const CPoseAsTransforms&, const rstl::optional_object< CVertexMorphEffect >&,
3941
const float*, float*);
4042
void Draw(const CModelFlags&) const;
43+
void Draw(const float* positions, const float* normals, const CModelFlags& flags) const;
44+
void DoDrawCallback(TDrawFunc func, void* data);
45+
void PostDrawFunc() const;
46+
47+
float* AllocateNewWorkspace(float** vertOut);
4148

4249
static void SetPointGeneratorFunc(void*, void (*)(void*, const CVector3f*, const CVector3f*, int));
4350
static void ClearPointGeneratorFunc();
51+
static void AddDummySkinnedModelRef();
4452
static void RemoveDummySkinnedModelRef();
4553

54+
void Construct();
55+
void AllocateStorage();
56+
static void TickAllocations();
57+
static void* EnsureAllocation(int size);
58+
59+
typedef void (*TPointGenFunc)(void*, const CVector3f*, const CVector3f*, int);
60+
static TPointGenFunc sPointGen;
61+
static void* sPointGenData;
62+
4663
private:
4764
TLockedToken< CModel > x4_model;
4865
TLockedToken< CSkinRules > x10_skinRules;
4966
TLockedToken< CCharLayoutInfo > x1c_layoutInfo;
50-
rstl::auto_ptr< float[] > x28_vertWorkspace;
51-
rstl::auto_ptr< float[] > x30_normalWorkspace;
67+
mutable rstl::auto_ptr< float > x28_vertWorkspace;
68+
mutable rstl::auto_ptr< float > x30_normalWorkspace;
5269
bool x38_owned;
5370
bool x39_disableWorkspaces;
5471
};
5572

5673
class CSkinnedModelWithAvgNormals {
5774
CSkinnedModel x0_skinnedModel;
58-
uchar x3c_pad[4];
59-
const float* x40_avgNormals;
75+
rstl::auto_ptr< float > x3c_avgNormals;
6076

6177
public:
78+
CSkinnedModelWithAvgNormals(const CSkinnedModel& model);
6279
const CSkinnedModel& GetSkinnedModel() const { return x0_skinnedModel; }
63-
const float* GetAvgNormals() const { return x40_avgNormals; }
80+
float* GetAvgNormals() const { return x3c_avgNormals.get(); }
6481
};
6582

6683
#endif // _CSKINNEDMODEL

include/Kyoto/Animation/CVirtualBone.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ class CVirtualBone {
1717
explicit CVirtualBone(CInputStream& in);
1818
const rstl::reserved_vector< SSkinWeighting, 3 >& GetWeights() const { return x0_weights; }
1919
uint GetVertexCount() const { return x1c_vertexCount; }
20+
const CTransform4f& GetTransform() const { return x20_xf; }
2021

2122
void BuildPoints(const ushort*, volatile void*, int) const;
2223
void BuildNormals(const ushort*, volatile void*, int) const;

include/Kyoto/Graphics/CModel.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ class CModel {
3030
CModel(const rstl::auto_ptr< uchar >& data, int length, IObjectStore& store);
3131
void Touch(int) const;
3232
void Draw(const CModelFlags&) const;
33+
void Draw(const float* positions, const float* normals, const CModelFlags& flags) const;
3334
bool IsLoaded(int matIdx) const;
3435
const float* GetPositions() const;
3536
const float* GetNormals() const;

include/dolphin/gx/GXFifo.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ void GXInitFifoLimits(GXFifoObj* fifo, u32 hiWaterMark, u32 loWaterMark);
2929
GXBreakPtCallback GXSetBreakPtCallback(GXBreakPtCallback cb);
3030
void GXEnableBreakPt(void* breakPt);
3131
void GXDisableBreakPt(void);
32+
volatile void* GXRedirectWriteGatherPipe(void* buf);
33+
void GXRestoreWriteGatherPipe(void);
3234

3335
#ifdef __cplusplus
3436
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#ifndef _RSTL_ALLOCATOR_AUTO_PTR
2+
#define _RSTL_ALLOCATOR_AUTO_PTR
3+
4+
#include "types.h"
5+
6+
namespace rstl {
7+
template < typename T, typename Alloc >
8+
struct allocator_auto_ptr {
9+
allocator_auto_ptr(T* ptr, Alloc* alloc) : x0_ptr(ptr), x4_alloc(alloc) {}
10+
~allocator_auto_ptr() {
11+
if (x0_ptr != nullptr) {
12+
x4_alloc->deallocate(x0_ptr);
13+
x0_ptr = nullptr;
14+
}
15+
}
16+
17+
T* release() const {
18+
T* ret = x0_ptr;
19+
const_cast< allocator_auto_ptr* >(this)->x0_ptr = nullptr;
20+
return ret;
21+
}
22+
23+
private:
24+
T* x0_ptr;
25+
Alloc* x4_alloc;
26+
};
27+
} // namespace rstl
28+
29+
#endif // _RSTL_ALLOCATOR_AUTO_PTR

include/rstl/list.hpp

Lines changed: 54 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,33 @@ class list {
2626
, xc_empty_prev(reinterpret_cast< node* >(&xc_empty_prev))
2727
, x10_empty_next(reinterpret_cast< node* >(&xc_empty_prev))
2828
, x14_count(0) {}
29+
30+
struct destroy_helper {
31+
destroy_helper(list* l) : x0_list(l), x4_active(true) {}
32+
~destroy_helper() {
33+
if (x4_active) {
34+
x0_list->destroy();
35+
}
36+
}
37+
void release() { x4_active = false; }
38+
39+
private:
40+
list* x0_list;
41+
bool x4_active;
42+
};
43+
44+
list(const list& other)
45+
: x0_allocator(other.x0_allocator)
46+
, x4_start(reinterpret_cast< node* >(&xc_empty_prev))
47+
, x8_end(reinterpret_cast< node* >(&xc_empty_prev))
48+
, xc_empty_prev(reinterpret_cast< node* >(&xc_empty_prev))
49+
, x10_empty_next(reinterpret_cast< node* >(&xc_empty_prev))
50+
, x14_count(0) {
51+
destroy_helper dh(this);
52+
insert(end(), other.begin(), other.end());
53+
dh.release();
54+
}
55+
2956
~list();
3057
node* do_erase(node* item);
3158

@@ -36,6 +63,9 @@ class list {
3663
int size() const { return x14_count; }
3764
bool empty() const { return x14_count == 0; }
3865

66+
T& front() { return *x4_start->get_value(); }
67+
const T& front() const { return *x4_start->get_value(); }
68+
3969
void pop_front() { erase(x4_start); }
4070

4171
iterator begin() { return iterator(x4_start); }
@@ -90,6 +120,28 @@ class list {
90120
return nn;
91121
}
92122

123+
iterator insert(const iterator& pos, const T& val) {
124+
do_insert_before(pos.get_node(), val);
125+
return pos;
126+
}
127+
128+
template < typename InputIterator >
129+
void insert(const iterator& pos, InputIterator first, InputIterator last) {
130+
node* cur = first.get_node();
131+
while (cur != last.get_node()) {
132+
do_insert_before(pos.get_node(), *cur->get_value());
133+
cur = cur->get_next();
134+
}
135+
}
136+
137+
void destroy() {
138+
node* end = x8_end;
139+
node* it = x4_start;
140+
while (it != end) {
141+
it = do_erase(it);
142+
}
143+
}
144+
93145
void remove(const T& val);
94146

95147
// TODO non-matching
@@ -184,7 +236,7 @@ list< T, Alloc >::~list() {
184236
node* it = cur;
185237
node* next = cur->get_next();
186238
cur = next;
187-
destroy(it->get_value());
239+
rstl::destroy(it->get_value());
188240
x0_allocator.deallocate(it);
189241
}
190242
}
@@ -197,7 +249,7 @@ typename list< T, Alloc >::node* list< T, Alloc >::do_erase(node* node) {
197249
}
198250
node->get_prev()->set_next(node->get_next());
199251
node->get_next()->set_prev(node->get_prev());
200-
destroy(node->get_value());
252+
rstl::destroy(node->get_value());
201253
x0_allocator.deallocate(node);
202254
x14_count--;
203255
return result;

include/rstl/vector.hpp

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,33 +3,14 @@
33

44
#include "types.h"
55

6+
#include "rstl/allocator_auto_ptr.hpp"
67
#include "rstl/iterator.hpp"
78
#include "rstl/pointer_iterator.hpp"
89
#include "rstl/rmemory_allocator.hpp"
910

1011
class CInputStream;
1112

1213
namespace rstl {
13-
template < typename T, typename Alloc >
14-
struct allocator_auto_ptr {
15-
allocator_auto_ptr(T* ptr, Alloc* alloc) : x0_ptr(ptr), x4_alloc(alloc) {}
16-
~allocator_auto_ptr() {
17-
if (x0_ptr != nullptr) {
18-
x4_alloc->deallocate(x0_ptr);
19-
x0_ptr = nullptr;
20-
}
21-
}
22-
23-
T* release() const {
24-
T* ret = x0_ptr;
25-
const_cast< allocator_auto_ptr* >(this)->x0_ptr = nullptr;
26-
return ret;
27-
}
28-
29-
private:
30-
T* x0_ptr;
31-
Alloc* x4_alloc;
32-
};
3314

3415
template < typename T, typename Alloc = rmemory_allocator >
3516
class vector {

0 commit comments

Comments
 (0)