Re: [fpc-pascal] AnsiString address changed

2024-03-18 Thread Sven Barth via fpc-pascal
Hairy Pixels via fpc-pascal schrieb am Mo., 18. März 2024, 13:30: > > > > On Mar 18, 2024, at 5:29 PM, Michael Van Canneyt via fpc-pascal < > fpc-pascal@lists.freepascal.org> wrote: > > > > Of course there must be, that's the whole point of copy-on-write. > > > > As soon as one reference is chang

Re: [fpc-pascal] AnsiString address changed

2024-03-18 Thread Tomas Hajny via fpc-pascal
On 2024-03-18 13:29, Hairy Pixels via fpc-pascal wrote: On Mar 18, 2024, at 5:29 PM, Michael Van Canneyt via fpc-pascal wrote: Of course there must be, that's the whole point of copy-on-write. As soon as one reference is changed, a copy is made if the reference count is larget than 1, and t

Re: [fpc-pascal] AnsiString address changed

2024-03-18 Thread Hairy Pixels via fpc-pascal
> On Mar 18, 2024, at 5:29 PM, Michael Van Canneyt via fpc-pascal > wrote: > > Of course there must be, that's the whole point of copy-on-write. > > As soon as one reference is changed, a copy is made if the reference count > is larget than 1, and this copy is changed. Oh, it does copy on wr

Re: [fpc-pascal] AnsiString address changed

2024-03-18 Thread Michael Van Canneyt via fpc-pascal
On Mon, 18 Mar 2024, Hairy Pixels via fpc-pascal wrote: On Mar 18, 2024, at 3:27 PM, Hairy Pixels wrote: Oh, it's a pointer to a pointer? I guess that explains how it can resize itself and not invalidate shared references, if those are even possible with AnsiString. Wait, that's total

Re: [fpc-pascal] AnsiString address changed

2024-03-18 Thread Marco van de Voort via fpc-pascal
Op 18-3-2024 om 09:27 schreef Hairy Pixels via fpc-pascal: do that, you'll have the same output 3 times. Oh, it's a pointer to a pointer? No, it is a pointer variable, but you take the address (@) of that pointer, which causes the second indirection _

Re: [fpc-pascal] AnsiString address changed

2024-03-18 Thread Hairy Pixels via fpc-pascal
> On Mar 18, 2024, at 3:27 PM, Hairy Pixels wrote: > > Oh, it's a pointer to a pointer? I guess that explains how it can resize > itself and not invalidate shared references, if those are even possible with > AnsiString. Wait, that's totally wrong. :) @s is the address of the local variable

Re: [fpc-pascal] AnsiString address changed

2024-03-18 Thread Hairy Pixels via fpc-pascal
> On Mar 18, 2024, at 1:52 PM, Michael Van Canneyt via fpc-pascal > wrote: > > An ansistring is a pointer to a memory block. > > You are printing the address of S1 and the address of S, i.e. the address of > the pointer itself, not the address of what S (or s1) points to. Obviously > the add

Re: [fpc-pascal] AnsiString address changed

2024-03-17 Thread Michael Van Canneyt via fpc-pascal
On Mon, 18 Mar 2024, Hairy Pixels via fpc-pascal wrote: Curious, why did the address of "s" change here? Shouldn't the AnsiString be incrementing a reference count and not actually changing the actual pointer or copying? Correct me if I'm wrong, AnsiString is ref counted when passing in/ou

[fpc-pascal] AnsiString address changed

2024-03-17 Thread Hairy Pixels via fpc-pascal
Curious, why did the address of "s" change here? Shouldn't the AnsiString be incrementing a reference count and not actually changing the actual pointer or copying? Correct me if I'm wrong, AnsiString is ref counted when passing in/out functions but copies on assignment so technically no two A

[fpc-pascal] AnsiString setlength and getmem.

2011-02-11 Thread Luis Fernando Del Aguila Mejía
(* Program One *) {$codepage utf8} {$Mode objfpc} Uses math,sysutils; Var cad:ansistring; c,n:longword; Begin c:=2**30; // 1 GiB n:=4; // with 3 & 4 at fpc 2.4.2, no show Out of Memory // with 3 & 4 at fpc 2.5.1, no show Out of Memory (02/11/2011 04:04p.m.

Re: [fpc-pascal] AnsiString

2011-01-25 Thread Jürgen Hestermann
Luis Fernando Del Aguila Mejía schrieb: > p:=pointer(cad1); > p:=p-8; > Write('memory address : ',longint(p),'='); //Must show Size, but shows reference count > Writeln(longint(p^)); I fail to see why you need to mess with the internals of ansistrings at all. What is the reason to access

Re: [fpc-pascal] AnsiString

2011-01-25 Thread David Emerson
Luis Fernando Del Aguila Mejía wrote: > The documentation > (http://www.freepascal.org/docs-html/prog/progsu146.html#x189-1990008.2.7) > says: > -8 Longint current string with size. > -4 Longint with reference count. > But, when I want access to that structure, I have to do it backwards.

[fpc-pascal] AnsiString

2011-01-25 Thread Luis Fernando Del Aguila Mejía
The documentation (http://www.freepascal.org/docs-html/prog/progsu146.html#x189-1990008.2.7) says: -8 Longint current string with size. -4 Longint with reference count. But, when I want access to that structure, I have to do it backwards. -8 Longint with reference count. -4 Longint cur

Re: [fpc-pascal] Ansistring not being freed on Halt(1)

2008-09-29 Thread Brad Campbell
Graeme Geldenhuys wrote: On Mon, Sep 29, 2008 at 11:19 AM, Brad Campbell <[EMAIL PROTECTED]> wrote: I'm chasing an issue with a program I have that is leaving an Ansistring unfreed on exit. It exists cleanly without using halt(), but this is the the only way I've managed to reproduce it. Should

Re: [fpc-pascal] Ansistring not being freed on Halt(1)

2008-09-29 Thread Graeme Geldenhuys
On Mon, Sep 29, 2008 at 11:19 AM, Brad Campbell <[EMAIL PROTECTED]> wrote: > I'm chasing an issue with a program I have that is leaving an Ansistring > unfreed on exit. It exists cleanly without using halt(), but this is the the > only way I've managed to reproduce it. > > Should Halt() leave memor

[fpc-pascal] Ansistring not being freed on Halt(1)

2008-09-29 Thread Brad Campbell
I'm chasing an issue with a program I have that is leaving an Ansistring unfreed on exit. It exists cleanly without using halt(), but this is the the only way I've managed to reproduce it. Should Halt() leave memory unfreed? It is only reproducible if I use ExtractFileName or ExtractFileExt.. (

Re: [fpc-pascal]ansistring and fillchar

2003-12-10 Thread Thomas Schatzl
Hello, > How can I use fillchar to give an ansistring a value of, say > 'x'? In other words, I want to create a string that contains > only a single character, that is repeated a certain number of times. E.g. this should work (with some typecasting ;-): {$MODE DELPHI} var s : AnsiSt

Re: [fpc-pascal]ansistring and fillchar

2003-12-10 Thread Michael Van Canneyt
On Tue, 9 Dec 2003, Mark Emerson wrote: > How can I use fillchar to give an ansistring a value of, say > 'x'? In other words, I want to create a string that contains > only a single character, that is repeated a certain number of times. Use S:=StringOfChar('X',30); Michael.

AW: [fpc-pascal]ansistring and fillchar

2003-12-10 Thread ZINTEL Gerhard
Hello Mark > > How can I use fillchar to give an ansistring a value of, say > 'x'? In other words, I want to create a string that contains > only a single character, that is repeated a certain number of times. > > Mark > There is an example in the reference guide for function FillC

[fpc-pascal]ansistring and fillchar

2003-12-09 Thread Mark Emerson
How can I use fillchar to give an ansistring a value of, say 'x'? In other words, I want to create a string that contains only a single character, that is repeated a certain number of times. Mark ___ fpc-pascal maillist - [EMAIL PROTECTED]