MCPcopy Create free account
hub / github.com/Kitware/VTK / vtkVRMLVectorType

Class vtkVRMLVectorType

IO/Import/vtkVRML.h:58–178  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

56
57template <class T>
58class vtkVRMLVectorType
59{
60public:
61 vtkVRMLVectorType(int usenew = 0)
62 : UseNew(usenew)
63 {
64 this->Init();
65 }
66
67 ~vtkVRMLVectorType()
68 {
69 if (this->UseNew)
70 {
71 delete[] this->Data;
72 }
73 }
74
75 void Init()
76 {
77 this->Allocated = DEFAULTINCREMENT;
78 if (!this->UseNew)
79 {
80 vtkVRMLAllocator::Initialize();
81 // NOLINTNEXTLINE(bugprone-sizeof-expression)
82 void* mem = vtkVRMLAllocator::AllocateMemory(this->Allocated * sizeof(T));
83 this->Data = new (mem) T[this->Allocated];
84 }
85 else
86 {
87 this->Data = new T[this->Allocated];
88 }
89 Used = 0;
90 }
91
92 void Reserve(int newSize)
93 {
94 if (newSize >= this->Allocated)
95 {
96 int oldSize = this->Allocated;
97 this->Allocated = newSize + DEFAULTINCREMENT;
98 T* temp = this->Data;
99 if (!this->UseNew)
100 {
101 // NOLINTNEXTLINE(bugprone-sizeof-expression)
102 void* mem = vtkVRMLAllocator::AllocateMemory(this->Allocated * sizeof(T));
103 this->Data = new (mem) T[this->Allocated];
104 }
105 else
106 {
107 this->Data = new T[this->Allocated];
108 }
109 if (this->Data == (T*)'\0')
110 {
111 return;
112 }
113 // NOLINTNEXTLINE(bugprone-sizeof-expression)
114 memcpy((void*)this->Data, (void*)temp, oldSize * sizeof(T));
115 if (this->UseNew)

Callers

nothing calls this directly

Calls 2

DemandMethod · 0.95
ReserveMethod · 0.95

Tested by

no test coverage detected