Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
AlquiWKT opened this issue Aug 24, 2023 · 3 comments
Open

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

AlquiWKT opened this issue Aug 24, 2023 · 3 comments

Comments

@AlquiWKT
Copy link

[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
Copy link
Author

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

@latdev
Copy link

latdev commented Jan 22, 2024

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
Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants