MCPcopy Create free account
hub / github.com/defold/defold / Alloc

Method Alloc

engine/dlib/src/dmsdk/dlib/object_pool.h:101–120  ·  view source on GitHub ↗

* Allocate a new object * @name Alloc * @return index [type:uint32_t] logical index */

Source from the content-addressed store, hash-verified

99 * @return index [type:uint32_t] logical index
100 */
101 uint32_t Alloc()
102 {
103 uint32_t size = m_Objects.Size();
104 Entry* e = 0;
105 if (m_FirstFree != 0xffffffff) {
106 e = &m_Entries[m_FirstFree];
107 m_FirstFree = e->m_Next;
108 } else {
109 m_Entries.SetSize(size + 1);
110 e = &m_Entries[size];
111 }
112 e->m_Next = 0xffffffff;
113 e->m_Physical = size;
114 m_Objects.SetSize(size + 1);
115
116 uint32_t index = e - m_Entries.Begin();
117 m_ToLogical[size] = index;
118
119 return index;
120 }
121
122 /*# get size
123 * Get number of objects currently stored

Callers 12

InstanceCreateFunction · 0.80
AllocateTimerFunction · 0.80
JobSystemCreateJobFunction · 0.80
TESTFunction · 0.80
fooFunction · 0.80
SetMaterialAttributeFunction · 0.80
CompMeshCreateFunction · 0.80
CompLabelCreateFunction · 0.80
CompSpriteCreateFunction · 0.80
CompModelCreateFunction · 0.80
CompSoundCreateFunction · 0.80
TEST_FFunction · 0.80

Calls 3

SizeMethod · 0.45
SetSizeMethod · 0.45
BeginMethod · 0.45

Tested by 3

TESTFunction · 0.64
fooFunction · 0.64
TEST_FFunction · 0.64