18 Resource::Resource(uint32_t elements)
22 m_isAllocated =
new bool[m_size];
23 for (uint32_t i=0; i < m_size; i++)
25 m_isAllocated[i] =
false;
54 delete[] m_isAllocated;
65 for (uint32_t i=0; i < m_size; i++)
67 if (!m_isAllocated[i])
69 m_isAllocated[i] =
true;
73 wpi_setWPIErrorWithContext(NoAvailableResources, resourceDesc);
87 wpi_setWPIErrorWithContext(ChannelIndexOutOfRange, resourceDesc);
90 if ( m_isAllocated[index] )
92 wpi_setWPIErrorWithContext(ResourceAlreadyAllocated, resourceDesc);
95 m_isAllocated[index] =
true;
108 if (index == ~0ul)
return;
111 wpi_setWPIError(NotAllocated);
114 if (!m_isAllocated[index])
116 wpi_setWPIError(NotAllocated);
119 m_isAllocated[index] =
false;
void Free(uint32_t index)
uint32_t Allocate(const char *resourceDesc)
static void CreateResourceObject(Resource **r, uint32_t elements)