void
JMMArrayTable::_AddNewRecord
	(
	const JMMRecord& record,
	const JBoolean   checkDoubleAllocation
	)
{
	JSize index = 0;

	if (checkDoubleAllocation)
		{
		index = FindAllocatedBlock( record.GetAddress() );
		}

	if (index == 0)
		{
		// Append because new allocations tend to be free'd the fastest
		itsAllocatedTable->AppendElement(record);
		}
	else
		{
		JMMRecord thisRecord = itsAllocatedTable->GetElement(index);
		itsAllocatedBytes   -= thisRecord.GetSize();

		NotifyMultipleAllocation(record, thisRecord);

		// Might as well trust malloc--the table should never have duplicate
		// entries!
		itsAllocatedTable->SetElement(index, record);
		}

	itsAllocatedBytes += record.GetSize();
}
Ejemplo n.º 2
0
void
JMMHashTable::_AddNewRecord
(
    const JMMRecord& record,
    const JBoolean   checkDoubleAllocation
)
{
    JHashCursor<JMMRecord> cursor(itsAllocatedTable, reinterpret_cast<JHashValue>( record.GetAddress() ) );
    if (checkDoubleAllocation)
    {
        cursor.ForceNextMapInsertHash();
        if ( cursor.IsFull() )
        {
            JMMRecord thisRecord = cursor.GetValue();
            itsAllocatedBytes   -= thisRecord.GetSize();
            NotifyMultipleAllocation(record, thisRecord);
        }
        // Might as well trust malloc--the table should never have duplicate
        // entries!
    }
    else
    {
        cursor.ForceNextOpen();
    }
    cursor.Set(reinterpret_cast<JHashValue>( record.GetAddress() ), record);
    itsAllocatedBytes += record.GetSize();
}