[fpc-pascal] Remove last character from pchar
Darius Blaszyk
dhkblaszyk at gmail.com
Thu Jun 10 18:19:47 CEST 2021
Hi,
I am a bit struggling with what should be fairly simple. I have a pchar
where I am adding and removing characters. What I did so far is to allocate
new memory every time and copying the source pchar over to a new one to
append or delete a character. This required two helper variables in order
to allow for the swap. This does not seem to be very efficient to me and I
was wondering if I am missing anything?
What also confused me in the beginning that assigning a string to a pchar
automatically assigns memory for that pchar. Is there a way to control
this? e.g. to switch this off and generate a compiler error or runtime
error when this happens? I'd like to prevent runtime errors or memory leaks
instead.
Thank you very much!
Rgds, Darius
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20210610/82a17588/attachment.htm>
More information about the fpc-pascal
mailing list