Recent

Author Topic: Do I need to free result of LeftStr/RightStr/etc?  (Read 3104 times)

ssawgift

  • New Member
  • *
  • Posts: 16
    • My Personal Website
Do I need to free result of LeftStr/RightStr/etc?
« on: December 11, 2021, 07:04:47 pm »
I read the doc about LeftStr/RightStr, but does not get a clue if I need to free the returned/copied string. Or Pascal runtime automatically handles memory allocations?

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 9986
  • FPC developer.
Re: Do I need to free result of LeftStr/RightStr/etc?
« Reply #1 on: December 11, 2021, 07:09:37 pm »
Pascal strings are automatically memory managed.  C strings (pchar/pansichar/pwidechar) aren't.

ssawgift

  • New Member
  • *
  • Posts: 16
    • My Personal Website
Re: Do I need to free result of LeftStr/RightStr/etc?
« Reply #2 on: December 11, 2021, 07:28:44 pm »
Pascal strings are automatically memory managed.  C strings (pchar/pansichar/pwidechar) aren't.
:o How I did not know that?

PascalDragon

  • Hero Member
  • *****
  • Posts: 4008
  • Compiler Developer
Re: Do I need to free result of LeftStr/RightStr/etc?
« Reply #3 on: December 13, 2021, 02:12:28 pm »
Pascal strings are automatically memory managed.  C strings (pchar/pansichar/pwidechar) aren't.
:o How I did not know that?

That is a good question considering that it's one of the main advantages of Pascal over C ;)

 

TinyPortal © 2005-2018