Khojasteh / simple-graph

A visual Delphi component for drawing simple directed graphs.
MIT License
21 stars 5 forks source link

Compiler Error in function Realloc in delphi CE Alexandria 11.3 #3

Open AlquiWKT opened 1 year ago

AlquiWKT commented 1 year ago

[dcc32 Error] SimpleGraph.pas(154): E2037 Declaration of 'Realloc' differs from previous declaration

[dcc32 Warning] SimpleGraph.pas(8051): W1000 Symbol 'StrPCopy' is deprecated: 'Moved to the AnsiStrings unit'

AlquiWKT commented 1 year ago

It's a very good component. In Delphi Rio 10.3 I work correctly. Impossible to compile in Delphi CE alexandria

latdev commented 10 months ago

New Dephi Redeclared var reference, now this looks like. function TMemoryStream.Realloc(var NewCapacity: NativeInt): Pointer; virtual;

But I just removed override directive from TMemoryHandleStream Realloc function. It makes warning [dcc32 Warning] SimpleGraph.pas(154): W1010 Method 'Realloc' hides virtual method of base type 'TMemoryStream' but works fine for me.

Ps: Thanks for author for good and simple component.

Khojasteh commented 10 months ago

Thank you for reaching out and for your interest in the component. I appreciate your efforts in modifying it for your use.

I wanted to inform you that I no longer write code in Delphi and do not actively maintain this component for newer versions of Delphi. However, I can still provide some general advice based on your description.

I noticed in your message that you have removed the override directive from the Realloc method in TMemoryHandleStream, which now leads to a method hiding a warning. This change is significant because Realloc is a critical method for memory management in TMemoryStream.

In Delphi, when a subclass method hides a virtual method of its base class (instead of overriding it), it can lead to unexpected behavior. Specifically for memory management functions like Realloc, not properly overriding this method could introduce issues such as null reference errors, buffer overflows, or memory leaks. This happens because the subclass may not handle memory in the way the base class method was designed to, potentially leading to improper memory allocation or deallocation.

Although I am not up-to-date with the latest Delphi practices, I would recommend revisiting this change. If TMemoryHandleStream is meant to have a different implementation of Realloc, it should properly override the base class method to ensure that memory management is handled correctly and safely. This will help maintain the stability and reliability of the component.