Tpm2Lib.Tbs.MakeSpace C# (CSharp) Method

MakeSpace() private method

Make a space in the TPM for an entity of type neededSlot (while not evicting another needed entity)
private MakeSpace ( SlotType neededSlot, ObjectContext doNotEvict ) : bool
neededSlot SlotType
doNotEvict ObjectContext
return bool
        private bool MakeSpace(SlotType neededSlot, ObjectContext[] doNotEvict)
        {
            ObjectContext entityToEvict = ContextManager.GetBestEvictionCandidate(neededSlot, doNotEvict);
            if (entityToEvict == null)
            {
                return false;
            }
            // Candidate is the entity that we need to evict. Save it, and then update our internal database.
            Context b = Tpm.ContextSave(entityToEvict.TheTpmHandle);
            entityToEvict.Context = b;
            // Non-session objects evict on their own.  Transient objects need to be evicted explictly.
            // TODO: Manage the saved-context array.
            if (neededSlot != SlotType.SessionSlot)
            {
                Tpm.FlushContext(entityToEvict.TheTpmHandle);
            }
            entityToEvict.TheTpmHandle = null;
            entityToEvict.Loaded = false;
            return true;
        }