Exemple #1
0
        /// <summary> Processes free operation for this callstack and updates lifecycles if needed. </summary>
        public FAllocationLifecycle ProcessFree(FStreamToken StreamToken)
        {
            int SizeChange = 0;
            FAllocationLifecycle Result = null;

            FAllocationLifecycle Lifecycle;

            if (IncompleteLifecycles.TryGetValue(StreamToken.Pointer, out Lifecycle))
            {
                SizeChange = -Lifecycle.CurrentSize;

                Lifecycle.Free(StreamToken);

                if (FStreamInfo.GlobalInstance.CreationOptions.KeepLifecyclesCheckBox.Checked)
                {
                    CompleteLifecycles.Add(Lifecycle);
                }
                IncompleteLifecycles.Remove(StreamToken.Pointer);

                Result = Lifecycle;
            }
            else
            {
                // this should be caught by the stream parser, but an extra check doesn't hurt
                Debug.WriteLine("Free without malloc! StreamIndex = " + StreamToken.StreamIndex);
            }

            LatestSize += SizeChange;

            // it's possible that this point was already added to the graph via realloc chain propagation
            if (SizeGraphPoints != null && (SizeGraphPoints.Count == 0 || SizeGraphPoints[SizeGraphPoints.Count - 1].StreamIndex != StreamToken.StreamIndex))
            {
                SizeGraphPoints.Add(new FSizeGraphPoint(StreamToken.StreamIndex, SizeChange, false));
            }

            return(Result);
        }