Board index » delphi » Pointers, Delphi's Internal Approach
Mark Mamon
![]() Delphi Developer |
Fri, 20 Jul 2001 03:00:00 GMT
|
Mark Mamon
![]() Delphi Developer |
Fri, 20 Jul 2001 03:00:00 GMT
Pointers, Delphi's Internal Approach
Can anybody explain or even better, point me to a resource, that
explains how delphi handles pointers. It appears that I need to pass the address of the first element in the case of arrays to get the actual memory address. From this I can only assume that Delphi has an internal table that the Its all so I can exactly understand what is being passed for examples such Thanks - MarkM |
Stefan Hoffmeist
![]() Delphi Developer |
Fri, 20 Jul 2001 03:00:00 GMT
Re:Pointers, Delphi's Internal Approach: "Mark Mamone" <mark.mam...@syntegra.bt.co.uk> wrote: Quote>Can anybody explain or even better, point me to a resource, that address. Period. Quote>Its all so I can exactly understand what is being passed for examples such var IOW, pointers in Delphi are like pointers in every other decent -- |
Ray Lischn
![]() Delphi Developer |
Fri, 20 Jul 2001 03:00:00 GMT
Re:Pointers, Delphi's Internal ApproachOn Mon, 1 Feb 1999 08:44:28 -0000, "Mark Mamone" Quote<mark.mam...@syntegra.bt.co.uk> wrote: model involves extra, hidden levels of indirection, you misunderstand them. Delphi doesn't do anything special or magic with pointers. Quote>From this I can only assume that Delphi has an internal table that the Quote>Its all so I can exactly understand what is being passed for examples such argument. -- Ray Lischner (http://www.bardware.com) co-author (with John Doyle) of Shakespeare for Dummies |
Mark Mamon
![]() Delphi Developer |
Sat, 21 Jul 2001 03:00:00 GMT
Re:Pointers, Delphi's Internal ApproachWhat is happening here then If I do the following pPointer : Pointer; pCharacter := StrAlloc(100); and I evalute them using CTRL+F7, I find the following The pPointer points to the actual data. The pCharacter holds an address The READ method of memory stream takes a 'var Buffer'. If I pass a character I'm confuse, please help! MarkM |
Robert Keith Eli
![]() Delphi Developer |
Sat, 21 Jul 2001 03:00:00 GMT
Re:Pointers, Delphi's Internal Approach Hi "Mark Mamone" <mark.mam...@syntegra.bt.co.uk>; This is a public reply to your message posted: I am just an interested observer, with one question and one suggestion. ~ > What is happening here then Does the address that pCharacter points to, contain the address of ~ > The READ method of memory stream takes a 'var Buffer'. If I pass a character As I understand it (and maybe I don't), 'var Buffer' takes the Cordially; -- --------- I consider ALL arguments in support of my views --------- |
Robert Le
![]() Delphi Developer |
Sat, 21 Jul 2001 03:00:00 GMT
Re:Pointers, Delphi's Internal ApproachQuoteMark Mamone wrote: arrays/strings. There is a lot of automatic converting/dereferencing that goes on with these types so that they can be used interchangeably. As far as the 'var buffer' goes, you should pass the array itself not its address. Var parameters take the address on their own. For example, the following two procedures have the exact same values being passed procedure DoStuffVar(var buffer); ... procedure DoStuffAddr(buffer:pointer); the difference is in how you use them. var If you're using D4 dynamic arrays, they too are automatically Bob Lee |
Robert Le
![]() Delphi Developer |
Sat, 21 Jul 2001 03:00:00 GMT
Re:Pointers, Delphi's Internal ApproachQuoteRobert Keith Elias wrote: passing pointers around is a way of life. I believe that you and Mark are making this way too complex, essentially As for var params. procedure One(var a:integer); is equivalent to: procedure Two(const a:^integer); the difference is that within the routines you get to use 'a' rather Bob Lee |
ullr..
![]() Delphi Developer |
Sat, 21 Jul 2001 03:00:00 GMT
Re:Pointers, Delphi's Internal ApproachIn article <796fmo$77...@pheidippides.axion.bt.co.uk>, "Mark Mamone" <mark.mam...@syntegra.bt.co.uk> wrote: Quote> What is happening here then of pCharacter. pCharacter is a 4-byte variable; it holds the address of that string. You don't want the location of the variable holding the address, you (presumably?) want the address of the string data itself. Ie you want the _contents_ of the pCharacter variable: pPointer := pCharacter; -----------== Posted via Deja News, The Discussion Network ==---------- |
VBDi
![]() Delphi Developer |
Sun, 22 Jul 2001 03:00:00 GMT
Re:Pointers, Delphi's Internal ApproachIm Artikel <36c5e93f.590892...@news.proaxis.com>, n...@junk.mail (Ray Lischner) Quote>An untyped var argument requires a variable, not a pointer as an indirection in Delphi and C++. Therefore I'd appreciate any contributions, that shed some light on the use of pointers in Delphi. It's not always clear, where (implicit) pointers occur, that need allocation of according memory. IMO both the original requestor and me know about pointers in C and on machine DoDi |
Mark Mamon
![]() Delphi Developer |
Sun, 22 Jul 2001 03:00:00 GMT
Re:Pointers, Delphi's Internal ApproachIt was the Evaluate that confused me, if I enter the POINTER it shows the address where the data is. If I enter the PCHAR it shows me the address that holds the pointer to where the data is. I assumed that as they were both pointers it should look the same but because PCHAR is a typed pointer, it knows a little more about it and is intelligent in its answer. I'd like to thank everybody for there help in me understanding this, and I I do come from a C++ background and to be honest the lack of thorough How does Delphi handle the PCHAR, Array of bytes, Pointers etc INTERNALLY, MarkM |
Robert Le
![]() Delphi Developer |
Sun, 22 Jul 2001 03:00:00 GMT
Re:Pointers, Delphi's Internal ApproachQuoteMark Mamone wrote: it you leak it". The reference count (as size info as well) are stored negative to the pointer value. Thus at p-4 you have a dword for the element count, and p-8 you have a ref count. (I'm not positive on the ref count location). In general, the heap manager does keep a list of allocated blocks and their sizes. That's why freemem doesn't need the size of the block any more. Bob Lee |
ullr..
![]() Delphi Developer |
Sun, 22 Jul 2001 03:00:00 GMT
Re:Pointers, Delphi's Internal ApproachIn article <19990202230535.03036.00001...@ngol02.aol.com>, vb...@aol.com (VBDis) wrote: Quote
Quote> IMO similar rules apply to the level of want a more specific answer you might ask a specific question. Quote> DoDi http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own |
Bruce Robert
![]() Delphi Developer |
Sun, 22 Jul 2001 03:00:00 GMT
Re:Pointers, Delphi's Internal ApproachQuote>How does Delphi handle the PCHAR, Array of bytes, Pointers etc INTERNALLY, |
Stefan Hoffmeist
![]() Delphi Developer |
Sun, 22 Jul 2001 03:00:00 GMT
Re:Pointers, Delphi's Internal Approach: Robert Lee <rh...@nwu.edu> wrote: Quote>negative to the pointer value. Thus at p-4 you have a dword for the element -- |
Ray Lischn
![]() Delphi Developer |
Sun, 22 Jul 2001 03:00:00 GMT
Re:Pointers, Delphi's Internal ApproachOn 03 Feb 1999 04:05:35 GMT, vb...@aol.com (VBDis) wrote: Quote>...Therefore I'd appreciate any contributions, that most significant difference isn't related to pointers per se, but objects, namely that all object references in Delphi are implicitly pointers, but that isn't the case in C++. Most of the problems Delphi users have with pointers are because they That isn't true with Delphi. Pascal in general and Delphi in particular avoid pointers in favor of In C or C++, the ReadBuffer procedure would use a pointer argument, so |
1. Delphi 5.0 and 'Internal Error URW3375'
2. Best approach for 'gather floppy'?
3. Interbase delphi 'Null Pointer exception'
4. Calling DLL's - Pointers to Pointers
5. Lotus Approach DBF's are read only!!
6. DIBs, Palettes, D4, what's the right approach
7. What's the best approach?!?
8. What's the best approach to dispatch com+ event over a network