function TStrIntfHashMap.Remove(const Key: string): IInterface;
var Bucket: PStrIntfBucket; I: Integer; {$IFDEF THREADSAFE} CS: IInterface; {$ENDIF} begin {$IFDEF THREADSAFE} CS := EnterCriticalSection; {$ENDIF} Result := nil; if Key = '' then Exit; Bucket := @(FBuckets[FHashFunction(HashString(Key))]); for I := 0 to Bucket.Count - 1 do if Bucket.Entries[I].Key = Key then begin //在Remove的时候仅仅只是返回了值,没有把Bucket.Entries[i]中的Value值进行置空。 Result := Bucket.Entries[I].Value; //add by mofen Bucket.Entries[I].Value := nil; System.Move(Bucket.Entries[I + 1], Bucket.Entries[I], (Bucket.Count - I) * SizeOf(TStrStrEntry)); Dec(Bucket.Count); Exit; end; end;
我看了所有的Remove针对对象和接口的释放都貌似有些问题。
|
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论