Exemplo n.º 1
0
	/** Default constructor. Preallocate space for items and header, then initialize header. */
	CFixedSizeArrayT()
	{
		/* allocate block for header + items (don't construct items) */
		m_items = (Titem*)((MallocT<int8>(ThdrSize + Tcapacity * sizeof(Titem))) + ThdrSize);
		SizeRef() = 0; // initial number of items
		RefCnt() = 1; // initial reference counter
	}
Exemplo n.º 2
0
	/** Default constructor. Preallocate space for items and header, then initialize header. */
	FixedSizeArray()
	{
		/* allocate block for header + items (don't construct items) */
		data = (T*)((MallocT<byte>(HeaderSize + C * Tsize)) + HeaderSize);
		SizeRef() = 0; // initial number of items
		RefCnt() = 1; // initial reference counter
	}
Exemplo n.º 3
0
	/** destroy remaining items and free the memory block */
	~CFixedSizeArrayT()
	{
		/* release one reference to the shared block */
		if ((--RefCnt()) > 0) return; // and return if there is still some owner

		Clear();
		/* free the memory block occupied by items */
		free(((int8*)m_items) - ThdrSize);
		m_items = NULL;
	}
Exemplo n.º 4
0
	/** destroy remaining items and free the memory block */
	~FixedSizeArray()
	{
		/* release one reference to the shared block */
		if ((--RefCnt()) > 0) return; // and return if there is still some owner

		Clear();
		/* free the memory block occupied by items */
		free(((byte*)data) - HeaderSize);
		data = NULL;
	}
Exemplo n.º 5
0
	/** Default constructor. Preallocate space for items and header, then initialize header. */
	FixedSizeArray()
	{
		/* Ensure the size won't overflow. */
		assert_compile(C < (SIZE_MAX - HeaderSize) / Tsize);

		/* allocate block for header + items (don't construct items) */
		data = (T*)((MallocT<byte>(HeaderSize + C * Tsize)) + HeaderSize);
		SizeRef() = 0; // initial number of items
		RefCnt() = 1; // initial reference counter
	}
Exemplo n.º 6
0
hsBool hsKeyedObject::MsgReceive(plMessage* msg)
{
    plSelfDestructMsg* nuke = plSelfDestructMsg::ConvertNoRef(msg);
    if (nuke)
    {
        hsAssert(RefCnt() == 1, "Trying to selfdestruct with bogus refcnt");
        hsRefCnt_SafeUnRef(this); 

        return true;
    }
    return plReceiver::MsgReceive(msg);
}
Exemplo n.º 7
0
	/** Copy constructor. Preallocate space for items and header, then initialize header. */
	CFixedSizeArrayT(const CFixedSizeArrayT<Titem_, Tcapacity_>& src)
	{
		/* share block (header + items) with the source array */
		m_items = src.m_items;
		RefCnt()++; // now we share block with the source
	}
Exemplo n.º 8
0
	/** Copy constructor. Preallocate space for items and header, then initialize header. */
	FixedSizeArray(const FixedSizeArray<T, C>& src)
	{
		/* share block (header + items) with the source array */
		data = src.data;
		RefCnt()++; // now we share block with the source
	}