Recent

Author Topic: dmath fft, got empty OutArray  (Read 2025 times)

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11459
  • FPC developer.
Re: dmath fft, got empty OutArray
« Reply #15 on: October 31, 2022, 12:59:50 pm »
Quote
I can't explain it deep into FPC level. I just follow the suggestion from here: http://synapse.ararat.cz/doku.php/public:howto:binarystring

Well, this recommendation was written in 2007, before managed dynamic arrays were introduced.

(Both Delphi and FPC supported dynamic arrays in 2007.  Delphi since nineties Delphi 4, and FPC since may 2005, but at that time many packages still kept compatibility with older Delphi versions)

Thaddy

  • Hero Member
  • *****
  • Posts: 14390
  • Sensorship about opinions does not belong here.
Re: dmath fft, got empty OutArray
« Reply #16 on: October 31, 2022, 01:06:03 pm »
Even in 2007 that was BAD advice.  >:D
It should have been solved by memory allocation and length.
But in 2007 we had already dynamic arrays.
Object Pascal programmers should get rid of their "component fetish" especially with the non-visuals.

glorfin

  • Full Member
  • ***
  • Posts: 148
  • LMath supporter
Re: dmath fft, got empty OutArray
« Reply #17 on: October 31, 2022, 04:02:48 pm »
Yes, I know that dynamic arrays did already exist. But were they managed as reference-counted? As far as I rememer, at the time one should have dispose them manually, with Finalize or SetLength(0).
(Though, I have to agree with Thaddy, even by the time using String for buffer was... strange advice).

senglit

  • Full Member
  • ***
  • Posts: 131
Re: dmath fft, got empty OutArray
« Reply #18 on: November 11, 2022, 01:36:04 pm »
I see. So I do not neet to SetLength(myArray,0) now? That's a good news :).

Yes, I know that dynamic arrays did already exist. But were they managed as reference-counted? As far as I rememer, at the time one should have dispose them manually, with Finalize or SetLength(0).
(Though, I have to agree with Thaddy, even by the time using String for buffer was... strange advice).
I use Win10 + Lazarus 2.2.0 + FPC 3.2.2. All 64bit.

Thaddy

  • Hero Member
  • *****
  • Posts: 14390
  • Sensorship about opinions does not belong here.
Re: dmath fft, got empty OutArray
« Reply #19 on: November 11, 2022, 01:43:26 pm »
To elaborate a bit:
If you use a string type to hold wave data, you usually start the wave data at zero, which means that the string is considered empty.... Since zero is a terminator for strings depending on its use: if the proper use of length is used that problem may disappear, but be careful: it is simply bad programming. Use a buffer and length.
« Last Edit: November 11, 2022, 01:45:52 pm by Thaddy »
Object Pascal programmers should get rid of their "component fetish" especially with the non-visuals.

 

TinyPortal © 2005-2018