Re: [fpc-pascal] Heap, Stack, HeapTrc and threads

2011-11-24 Thread andrew.bennett
On: Thu, 24 Nov 2011 17:06:18 +0100 Jonas Maebe wrote > On 24 Nov 2011, at 16:28, > > wrote: > > ... > > only odd thing was that TotalAllocated sometimes came back negative in > > the threads as the program approached the point of running out of > > memory > > The fact that the heap

[fpc-pascal] Heap, Stack, HeapTrc and threads

2011-11-24 Thread andrew.bennett
A recent query: Date: Mon, 21 Nov 2011 08:27:16 + From: Mark Morgan Lloyd Subject: [fpc-pascal] Debugging ancient heap allocation seems not to have received a reply. The problem of debugging memory allocation, however, is wider and not just involving ancient code! I am using: Compiler 2.4

[fpc-pascal] Re: More fun with dynamic arrays

2011-11-19 Thread andrew.bennett
On Fri, 18 Nov 2011 23:11:14 -0800 (PST) leledumbo wrote re use of "Out" parameters > ... As stated in the > docs (http://www.freepascal.org/docs-html/ref/refsu57.html): "The initial > value of the parameter on function entry is discarded, and should not be > used." which is why you get 0

[fpc-pascal] More fun with dynamic arrays

2011-11-17 Thread andrew.bennett
This program: Program TestMem ; Const ASize = 1000 ; Type DataA = Array Of Longint ; Var A : DataA ; Procedure Init(Out X : DataA ; Const N : Longint) ; Begin Writeln(Length(X)) ; { Writes: 0 } End ; Begin SetLength(A, ASize) ; Writeln(Length(A)) ; { Writes: 1000 as expected } Init(A, ASiz

RE : [fpc-pascal] Problem passing pointers to "hidden" procedure

2011-10-15 Thread andrew.bennett
On Sat, 15 Oct 2011 09:24:36 +0200 "Ludo Brands" wrote >On Fri, 14 Oct 2011 20:01:47 -0300 >wrote >> When the routine being passed as a parameter is in the top >> level of the >> unit, "PrPublic", all is well; the expected pointers are >> passed. When an >> identical routine "PrPrivate" is h

[fpc-pascal] Problem passing pointers to "hidden" procedure

2011-10-14 Thread andrew.bennett
As part of an attempt at multi-threading, I have had to move many things that used to be global into the Implementation parts of units in order to enforce privacy. When I moved a routine passed as a parameter and put it inside the routine to be threaded, the program ceased to work. I append the es

[fpc-pascal] Re: Register variables slowing down floating point operations

2011-05-14 Thread andrew.bennett
On Thu, 12 May 2011 20:54:16 +0200 cobines wrote > I have written the following program: > ... > max := 1; > for i := 0 to max do > vd := i / max; A really smart compiler would notice that this in this loop the value of vd is never examined, the loop being equivalent to

Re: [fpc-pascal] 2D Dynamic arrays and BlockRead

2010-12-07 Thread andrew.bennett
Marc Weustink wrote >On 3-12-2010 17:26, Jürgen Hestermann wrote: >> ... >> STat = Array[0..W-1] Of Single ; { Static array } >> DST = Array Of STat ; { One dimension dynamic, the other static } >> D2T = Array Of Array Of Single ; { Two dynamic dimensions } >> >> STat always means the addres

Re: [fpc-pascal] 2D Dynamic arrays and BlockRead

2010-12-05 Thread andrew.bennett
J?rgen Hestermann wrote >andrew.benn...@ns.sympatico.ca schrieb: >> After using BlockRead to fill a 2D dynamic array, I get an access >>violation on the very first reference. A 2D array with only one >>dimension dynamic works OK. What am I missing? > >Maybe you blundered into the same tra

[fpc-pascal] 2D Dynamic arrays and BlockRead

2010-12-02 Thread andrew.bennett
After using BlockRead to fill a 2D dynamic array, I get an access violation on the very first reference. A 2D array with only one dimension dynamic works OK. What am I missing? Windows, FPC 2.2.2, 2.2.4 or 2.4.2. Program WriteA ; { Write a binary file using using static array and BlockWrite } C