Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2009-06

Re: JUNK: fpc-pascal Digest, Vol 60, Issue 12

2 messages · 1 person · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Richard Jasmin

-snip-

agreed.

This looks like TMemory manager reimplementation from the unit called via the system unit.[an include somewhere.don't ask me which one, I have been over the RTL half a dozen times this past week looking for includes....] I think its in ossys.inc and heap/heaph.inc.The TMemory manager construct is a known dependancy loop.

(you have to use the include file or it doesn't build.)

IE:
$include heaph.inc

Reply by email

Richard Jasmin

I have similar issue, at least with TP7(which is hard to find, I actually, HAD a legit copy back then....)
You can't write/read a record, you have to store strings into arrays then put those into records, link list them, use them, then RE-store the data into strings and write out the file.If anyone knows a more efficient way to do this, I'm all ears.I use records and linked lists extensively as database items and screen 'pages' and would like to continue using them as such.It seems nearly impossible to import a text file into a record file this way and I would rather not retype all of my database entries.

I'm working on the LCARS backend, I have the C sources for the GUI from sourceforge.Mind you, I'll have to rewrite the code again, but I did have something workable beyond an extensive menu system a while back.Might still be online in cache somewhere. It's called C4DB, and no, not the one on 'Mobius Caverns', that was an HTML version of it, I actually had a dos program of this, and couldn't port it as i was stuck with the limitations of TP7 on dos.I was about to add in image units when I scrapped the code way too many times.

Show quoted text 398 lines
Send fpc-pascal mailing list submissions to To subscribe or unsubscribe via the World Wide Web, visit http://lists.freepascal.org/mailman/listinfo/fpc-pascal or, via email, send a message with subject or body 'help' to You can reach the person managing the list at When replying, please edit your Subject line so it is more specific than "Re: Contents of fpc-pascal digest..." Today's Topics: 1. Strange error (Hans M?rtensson) 2. Re: Records as properties and Delphi compiler error () 3. RE: Re: [fpc-pascal] Gecko / Firefox / XPCOM (Henrik Genssen) 4. RE: Re: [fpc-pascal] Gecko / Firefox / XPCOM (Henrik Genssen) 5. Re: Records as properties and Delphi compiler error (Graeme Geldenhuys) 6. Re: Strange error (Vincent Snijders) 7. Re: Records as properties and Delphi compiler error () 8. Re: Records as properties and Delphi compiler error (Martin Friebe) ---------------------------------------------------------------------- Message: 1 Date: Mon, 08 Jun 2009 18:12:11 +0200 From: Hans M?rtensson Subject: [fpc-pascal] Strange error To: Free Pascal mailing list Message-ID: Content-Type: text/plain; charset=ISO-8859-1; format=flowed When compiling a windows program with FPC version 2.2.4 with the switch -dDEBUG (using the default configuration), after running the program I get the following message: ----------------------------- Error Heap dump by heaptrc unit 0 memory blocks allocated: 0/0 0 memory blocks freed: 0/0 0 unfreed memory blocks: 0 True heap size: 65536 (80 used in System startup) True free heap: 65456 ------------------------------- Is this: -A joke? -An error in the error message? -Indicationg some problem with my program? and if so, how can I find it? regards Hans Maartensson ------------------------------ Message: 2 Date: Mon, 8 Jun 2009 19:02:00 +0200 From: Subject: Re: [fpc-pascal] Records as properties and Delphi compiler error To: "FPC-Pascal users discussions" Message-ID: Content-Type: text/plain; charset="iso-8859-1" On Sunday 07 June 2009 22:19:47 Jonas Maebe wrote: > On 07 Jun 2009, at 10:35, wrote: > >> A high level, a class is like a record that has been modified to >> include >> functions and procedures. I know that I'm over simplifying thing >> here, please >> bare with me. >> > The difference you skip over is the fundamental reason why one works > and the other doesn't: a class is a pointer, while a record is a value. > I understand the difference, but a pointer to a record still suffers the from the same problem as a pointer to a class i.e. if memory is not allocated then the code 's interesting to note though, that Delphi allows the assignment to the fields of a record type property via the with - do construct. Is this also the case with FPC 2.3.1? >> I'm trying to understand the logic employed by the creators of >> Delphi where >> they don't allow to write to the fields of a record type property, >> but if the >> property points to a class type, then anything goes. >> > In case of a class, the property returns a pointer (namely the pointer > to the class instance data), and then you (implicitly) dereference the > pointer and write data where it points to. In case of a record, the > property returns a record's value, and then (semantically) you change > the value of this returned record (not the value of the element of the > record that the property referred to). > > This worked in previous FPC versions because rather than treating the > result of the property like a function result (which it has to, > because that's the semantical meaning of a property, so you can > transparently change them into getters/setters without breaking any > code), it treated it like a direct field access in case no getter/ > setter existed. So rather than returning a record's value, the > property returned "a reference to a record". > > >> In the example bellow, >> where a property is of a class type, both Delphi and FPC compile the >> code, >> but there is no guarantee that the object referenced to by the >> property has >> been instantiated before the property is used (The programmer must >> instantiate the TTestProp class within TTestClass prior to any call >> made to xx >> the property). IMO, it would be a nice feature if the compiler could >> be >> modified to issue a warning in such a case.Again, I'm over >> simplifying, to >> the compiler, it would be similar to checking for a variable >> declaration >> before the variable is used. >> > Except that it's about dynamically allocated memory and depends on > interprocedural control flow graph analysis, which makes it immensely > more complex. > > >> I thing that the "error" in the way that FPC allows record >> properties to >> access the record fields could be handy if retained. Perhaps this >> feature >> could be reserved for objfpc mode. What are your thoughts on the >> matter? >> > Things will remain the way they are for the reasons explained above. > > > Jonas > _______________________________________________ > fpc-pascal maillist - > http://lists.freepascal.org/mailman/listinfo/fpc-pascal > ------------------------------ Message: 3 Date: Mon, 8 Jun 2009 18:16:16 +0200 From: "Henrik Genssen" Subject: RE: Re: [fpc-pascal] Gecko / Firefox / XPCOM To: "FPC-Pascal users discussions" Message-ID: Content-Type: text/plain; charset="iso-8859-1" no, I did not know that. Thanx for the hint - but its stuck to QT :-( therefor I am more interested in gecko... > reply to message: > date: 24.05.2009 15:15:50 > from: "Den Jean" > to: "FPC-Pascal users discussions" > subject: Re: [fpc-pascal] Gecko / Firefox / XPCOM > > On Thursday 21 May 2009 22:34:52 Henrik Genssen wrote: > >> I am trying to use the gecko libs from >> http://sourceforge.net/projects/d-gecko with lazarus. >> > in case you didn't know > http://lists.lazarus.freepascal.org/pipermail/qt/2009-May/001212.html > _______________________________________________ > fpc-pascal maillist - > http://lists.freepascal.org/mailman/listinfo/fpc-pascal > > ------------------------------ Message: 4 Date: Mon, 8 Jun 2009 18:29:43 +0200 From: "Henrik Genssen" Subject: RE: Re: [fpc-pascal] Gecko / Firefox / XPCOM To: "FPC-Pascal users discussions" Message-ID: Content-Type: text/plain; charset="iso-8859-1" so how can this unit be converted to FPC, as the Memorymanager of FPC seems to differ from delphi... unit nsMemory; {$MODE Delphi} interface uses nsXPCOM; const NS_MEMORY_CONTRACTID = '@mozilla.org/xpcom/memory-service;1'; NS_MEMORY_CLASSNAME = 'Global Memory Service'; NS_MEMORY_CID: TGUID = '{30a04e40-38e7-11d4-8cf5-0060b0fc14a3}'; function Alloc(size: Integer): Pointer; function Realloc(ptr: Pointer; size: Integer): Pointer; function Free(ptr: Pointer): Integer; function HeapMinimize(aImmediate: Boolean): Longword; function Clone(Ptr: Pointer; size: Longword): Pointer; function GetGlobalMemoryService: nsIMemory; function GlueStartupMemory: Longword; procedure GlueShutdownMemory; procedure SetToMemoryManager; implementation uses nsError, nsInit; var gMemory: nsIMemory; procedure FreeGlobalMemory; begin gMemory := nil; end; function SetupGlobalMemory: nsIMemory; begin if Assigned(gMemory) then Exit; nsInit.NS_GetMemoryManager(gMemory); if not Assigned(gMemory) then Exit; Result := gMemory; end; function GlueStartupMemory: Longword; begin Result := NS_ERROR_FAILURE; if Assigned(gMemory) then Exit; nsInit.NS_GetMemoryManager(gMemory); if not Assigned(gMemory) then Exit; Result := NS_OK; end; procedure GlueShutdownMemory; begin gMemory := nil; end; function ENSURE_ALLOCATOR: Boolean; begin Result := True; if not Assigned(gMemory) and not Assigned(SetupGlobalMemory()) then Result := False; end; function Alloc(size: Integer): Pointer; begin Result := nil; if ENSURE_ALLOCATOR then Result := gMemory.Alloc(size); end; function Realloc(ptr: Pointer; size: Integer): Pointer; begin Result := nil; if ENSURE_ALLOCATOR then Result := gMemory.Realloc(ptr, size); end; function Free(ptr: Pointer): Integer; begin Result := NS_OK; if ENSURE_ALLOCATOR then gMemory.Free(ptr) else Result := Integer(NS_ERROR_UNEXPECTED); end; function HeapMinimize(aImmediate: Boolean): Longword; begin Result := NS_ERROR_FAILURE; if ENSURE_ALLOCATOR then try Result := NS_OK; gMemory.HeapMinimize(aImmediate); except Result := NS_ERROR_FAILURE; end; end; function Clone(ptr: Pointer; size: Longword): Pointer; begin Result := nil; if ENSURE_ALLOCATOR then Result := Clone(Ptr, size); end; function GetGlobalMemoryService: nsIMemory; begin Result := nil; if not ENSURE_ALLOCATOR then Exit; Result := gMemory; end; const memmgr: TMemoryManager = ( GetMem: Alloc; FreeMem: Free; ReallocMem: Realloc; ); procedure SetToMemoryManager; begin SetMemoryManager(memmgr); end; end. > reply to message: > date: 24.05.2009 18:28:19 > from: "Flávio Etrusco" > to: "FPC-Pascal users discussions" > subject: Re: [fpc-pascal] Gecko / Firefox / XPCOM > > On Sun, May 24, 2009 at 9:30 AM, Jonas Maebe wrote: > >> On 21 May 2009, at 22:34, Henrik Genssen wrote: >> >> >>> nsMemory.pas(157,17) Error: Incompatible types: got "Realloc(Pointer, >>> LongInt):^untyped" expected "<procedure variable type of function(var >>> Pointer, LongInt):^untyped;Register>" >>> >> As the error message says: the compiler expects the first parameter of >> realloc to be a "var" parameter, while the declaration of realloc apparently >> uses a value parameter. >> >> >> Jonas >> > Oops. I guess I assumed the code was the other way around: that the > gecko runtime accepted an application-provided mem-allocation > routines, and barely read the message :-$ > BTW, regarding the remaining Warnings from the OP: is there any > optional member in TMemoryManager or do all of them need to be setup? > > -Flávio > _______________________________________________ > fpc-pascal maillist - > http://lists.freepascal.org/mailman/listinfo/fpc-pascal > > ------------------------------ Message: 5 Date: Mon, 08 Jun 2009 19:55:00 +0200 From: Graeme Geldenhuys Subject: Re: [fpc-pascal] Records as properties and Delphi compiler error To: FPC-Pascal users discussions Message-ID: Content-Type: text/plain; charset=UTF-8; format=flowed Hi Nino, Can you please refrain from quoting the *whole* previous message, when your reply only relates to one or two lines. If other developers want to read the whole context of the message thread they can look in their email history or the mailing list archive. It is REALLY annoying seeing 80 lines in a message and then only 3 of those lines are actually the reply and the other 77 line are quoted text!

Reply by email