Rocksolid Light

News from da outaworlds

mail  files  register  groups  login

Message-ID:  

BOFH excuse #327: The POP server is out of Coke


comp / comp.lang.c / Re: realloc() - frequency, conditions, or experiences about relocation?

SubjectAuthor
* realloc() - frequency, conditions, or experiences about relocation?Janis Papanagnou
+* Re: realloc() - frequency, conditions, or experiences about relocation?Bonita Montero
|`* Re: realloc() - frequency, conditions, or experiences about relocation?Vir Campestris
| `* Re: realloc() - frequency, conditions, or experiences about relocation?Bonita Montero
|  `* Re: realloc() - frequency, conditions, or experiences about relocation?Lawrence D'Oliveiro
|   +* Re: realloc() - frequency, conditions, or experiences about relocation?Keith Thompson
|   |+* Re: realloc() - frequency, conditions, or experiences about relocation?David Brown
|   ||+* Re: realloc() - frequency, conditions, or experiences about relocation?Malcolm McLean
|   |||+* Re: realloc() - frequency, conditions, or experiences about relocation?Scott Lurndal
|   ||||`* Re: realloc() - frequency, conditions, or experiences about relocation?Keith Thompson
|   |||| +- Re: realloc() - frequency, conditions, or experiences about relocation?Malcolm McLean
|   |||| `- Re: realloc() - frequency, conditions, or experiences about relocation?Chris M. Thomasson
|   |||`* Re: realloc() - frequency, conditions, or experiences about relocation?Lawrence D'Oliveiro
|   ||| `* Re: realloc() - frequency, conditions, or experiences about relocation?Bonita Montero
|   |||  `- Re: realloc() - frequency, conditions, or experiences about relocation?Lawrence D'Oliveiro
|   ||+* Re: realloc() - frequency, conditions, or experiences about relocation?Chris M. Thomasson
|   |||`- Re: realloc() - frequency, conditions, or experiences about relocation?Bonita Montero
|   ||`- Re: realloc() - frequency, conditions, or experiences about relocation?Lawrence D'Oliveiro
|   |+- Re: realloc() - frequency, conditions, or experiences about relocation?Bonita Montero
|   |`* Re: realloc() - frequency, conditions, or experiences about relocation?Lawrence D'Oliveiro
|   | +* Re: realloc() - frequency, conditions, or experiences about relocation?Keith Thompson
|   | |+- Re: realloc() - frequency, conditions, or experiences about relocation?Richard Damon
|   | |+* Re: realloc() - frequency, conditions, or experiences about relocation?Phil Carmody
|   | ||`- Re: realloc() - frequency, conditions, or experiences about relocation?Keith Thompson
|   | |`* Re: realloc() - frequency, conditions, or experiences about relocation?James Kuyper
|   | | `- Re: realloc() - frequency, conditions, or experiences about relocation?Keith Thompson
|   | `- Re: realloc() - frequency, conditions, or experiences about relocation?James Kuyper
|   `* Re: realloc() - frequency, conditions, or experiences about relocation?Bonita Montero
|    `* Down the hall, past the water cooler, third door on the left... (Was: realloc() Kenny McCormack
|     `- Re: Down the hall, past the water cooler, third door on the left...Bonita Montero
+* Re: realloc() - frequency, conditions, or experiences about relocation?Ben Bacarisse
|`* Re: realloc() - frequency, conditions, or experiences about relocation?Malcolm McLean
| +* Re: realloc() - frequency, conditions, or experiences about relocation?Ben Bacarisse
| |`* Re: realloc() - frequency, conditions, or experiences about relocation?Malcolm McLean
| | +* Re: realloc() - frequency, conditions, or experiences about relocation?Ben Bacarisse
| | |+* Re: realloc() - frequency, conditions, or experiences about relocation?Anton Shepelev
| | ||`* Re: realloc() - frequency, conditions, or experiences about relocation?Tim Rentsch
| | || +* Indefinite pronouns [was:Re: realloc() - frequency, conditions, or experiences aAnton Shepelev
| | || |+* Re: Indefinite pronounsvallor
| | || ||`* Re: Indefinite pronounsDavid Brown
| | || || `- Re: Indefinite pronounsKeith Thompson
| | || |+- Re: Indefinite pronouns [was:Re: realloc() - frequency, conditions, or experiencTim Rentsch
| | || |+- Re: Indefinite pronouns [was:Re: realloc() - frequency, conditions, or experiencCri-Cri
| | || |`* Re: Indefinite pronouns [was:Re: realloc() - frequency, conditions, or experiencKenny McCormack
| | || | `- Re: Indefinite pronouns [was: Re: <something technical>]Janis Papanagnou
| | || `* Re: realloc() - frequency, conditions, or experiences about relocation?Malcolm McLean
| | ||  +* Re: realloc() - frequency, conditions, or experiences about relocation?Malcolm McLean
| | ||  |`* Re: realloc() - frequency, conditions, or experiences about relocation?Lawrence D'Oliveiro
| | ||  | `* Re: realloc() - frequency, conditions, or experiences about relocation?Malcolm McLean
| | ||  |  +- Re: realloc() - frequency, conditions, or experiences about relocation?Ben Bacarisse
| | ||  |  `- Re: realloc() - frequency, conditions, or experiences about relocation?Lawrence D'Oliveiro
| | ||  `* Re: realloc() - frequency, conditions, or experiences about relocation?Tim Rentsch
| | ||   `- Re: realloc() - frequency, conditions, or experiences about relocation?David Brown
| | |+* Re: realloc() - frequency, conditions, or experiences about relocation?Richard Harnden
| | ||`- Re: realloc() - frequency, conditions, or experiences about relocation?Chris M. Thomasson
| | |`- Re: realloc() - frequency, conditions, or experiences about relocation?Malcolm McLean
| | +* Re: realloc() - frequency, conditions, or experiences about relocation?Anton Shepelev
| | |+* Re: realloc() - frequency, conditions, or experiences about relocation?David Duffy
| | ||+* Re: realloc() - frequency, conditions, or experiences about relocation?Malcolm McLean
| | |||+* Re: realloc() - frequency, conditions, or experiences about relocation?Ben Bacarisse
| | ||||`* Re: realloc() - frequency, conditions, or experiences about relocation?David Brown
| | |||| `* Re: realloc() - frequency, conditions, or experiences about relocation?Ben Bacarisse
| | ||||  `- Re: realloc() - frequency, conditions, or experiences about relocation?David Brown
| | |||`* Re: realloc() - frequency, conditions, or experiences about relocation?Anton Shepelev
| | ||| `- Re: realloc() - frequency, conditions, or experiences about relocation?Anton Shepelev
| | ||`- Re: realloc() - frequency, conditions, or experiences about relocation?Anton Shepelev
| | |+- Re: realloc() - frequency, conditions, or experiences about relocation?David Jones
| | |`* Re: realloc() - frequency, conditions, or experiences about relocation?Rich Ulrich
| | | +* Re: realloc() - frequency, conditions, or experiences about relocation?Keith Thompson
| | | |`* Re: realloc() - frequency, conditions, or experiences about relocation?Rich Ulrich
| | | | `* Re: realloc() - frequency, conditions, or experiences about relocation?Anton Shepelev
| | | |  `* Re: realloc() - frequency, conditions, or experiences about relocation?Rich Ulrich
| | | |   `- Re: realloc() - frequency, conditions, or experiences about relocation?Anton Shepelev
| | | `* Re: realloc() - frequency, conditions, or experiences about relocation?Paul
| | |  `* Re: realloc() - frequency, conditions, or experiences about relocation?Rich Ulrich
| | |   `* Re: realloc() - frequency, conditions, or experiences about relocation?Rich Ulrich
| | |    `* Re: realloc() - frequency, conditions, or experiences about relocation?Paul
| | |     +- Re: realloc() - frequency, conditions, or experiences about relocation?James Kuyper
| | |     `- Re: realloc() - frequency, conditions, or experiences about relocation?James Kuyper
| | +* Re: realloc() - frequency, conditions, or experiences about relocation?Keith Thompson
| | |+- Re: realloc() - frequency, conditions, or experiences about relocation?Bonita Montero
| | |`- Re: realloc() - frequency, conditions, or experiences about relocation?Malcolm McLean
| | `* Re: realloc() - frequency, conditions, or experiences about relocation?Scott Lurndal
| |  `- Re: realloc() - frequency, conditions, or experiences about relocation?Chris M. Thomasson
| `- Re: realloc() - frequency, conditions, or experiences about relocation?David Brown
+- Re: realloc() - frequency, conditions, or experiences about relocation?Rosario19
+* Re: realloc() - frequency, conditions, or experiences about relocation?Scott Lurndal
|`* Re: realloc() - frequency, conditions, or experiences about relocation?Michael S
| `- Re: realloc() - frequency, conditions, or experiences about relocation?Scott Lurndal
+- Re: realloc() - frequency, conditions, or experiences about relocation?Janis Papanagnou
+* Re: realloc() - frequency, conditions, or experiences about relocation?David Brown
|`- Re: realloc() - frequency, conditions, or experiences about relocation?Bonita Montero
+- Re: realloc() - frequency, conditions, or experiences about relocation?Chris M. Thomasson
`* Re: realloc() - frequency, conditions, or experiences about relocation?Bonita Montero
 +* Re: realloc() - frequency, conditions, or experiences about relocation?Vir Campestris
 |`* Re: realloc() - frequency, conditions, or experiences about relocation?Bonita Montero
 | `* Re: realloc() - frequency, conditions, or experiences about relocation?Vir Campestris
 |  `- Re: realloc() - frequency, conditions, or experiences about relocation?Bonita Montero
 `* Re: realloc() - frequency, conditions, or experiences about relocation?DFS
  `- Re: realloc() - frequency, conditions, or experiences about relocation?Bonita Montero

Pages:1234
Subject: Re: realloc() - frequency, conditions, or experiences about relocation?
From: Bonita Montero
Newsgroups: comp.lang.c
Organization: A noiseless patient Spider
Date: Tue, 18 Jun 2024 07:56 UTC
References: 1 2 3 4 5 6
Path: eternal-september.org!news.eternal-september.org!raubtier-asyl.eternal-september.org!.POSTED!not-for-mail
From: Bonita.Montero@gmail.com (Bonita Montero)
Newsgroups: comp.lang.c
Subject: Re: realloc() - frequency, conditions, or experiences about
relocation?
Date: Tue, 18 Jun 2024 09:56:07 +0200
Organization: A noiseless patient Spider
Lines: 12
Message-ID: <v4rein$18e5u$1@raubtier-asyl.eternal-september.org>
References: <v4ojs8$gvji$1@dont-email.me> <875xu8vsen.fsf@bsb.me.uk>
<v4ovqf$j5hq$1@dont-email.me> <87zfrjvqp6.fsf@bsb.me.uk>
<v4pb4v$lhgk$1@dont-email.me> <87h6dr16md.fsf@nosuchdomain.example.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 18 Jun 2024 09:56:07 +0200 (CEST)
Injection-Info: raubtier-asyl.eternal-september.org; posting-host="685e4851f2faab722862bf26e2e83cf9";
logging-data="1325246"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX181DTpI8/It2wf9D781vFz33DdTUFmYBqA="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:341FV8FR3d6lmnAedeTP21wy6ZY=
Content-Language: de-DE
In-Reply-To: <87h6dr16md.fsf@nosuchdomain.example.com>
View all headers

Am 18.06.2024 um 01:39 schrieb Keith Thompson:

> I have a small test program that uses realloc() to expand a 1-byte
> allocated buffer to 2 bytes, then 3, then 4, and so on. In one
> implementation, in one test run, it reallocates at 25 bytes, and
> then not again until just over 128 kbytes. Other implementations
> behave differently.

Usually you don't expand a dynamic array byte per byte. Normaly you
expand it like a C++ vector whose capacity doubles with libstdc++
and libc++ (MSVC adds 50% to the capacity before).

Subject: Re: realloc() - frequency, conditions, or experiences about relocation?
From: Rosario19
Newsgroups: comp.lang.c
Organization: A noiseless patient Spider
Date: Tue, 18 Jun 2024 09:50 UTC
References: 1
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Ros@invalid.invalid (Rosario19)
Newsgroups: comp.lang.c
Subject: Re: realloc() - frequency, conditions, or experiences about relocation?
Date: Tue, 18 Jun 2024 11:50:48 +0200
Organization: A noiseless patient Spider
Lines: 18
Message-ID: <aul27jh5mpr74c00npt2837ko62f8os1v0@4ax.com>
References: <v4ojs8$gvji$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 18 Jun 2024 11:50:42 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="8447731d54af59021ed93362b9a23686";
logging-data="1368779"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/dhTeQQIAp/9KE6bpdABQNgoxjpliUT78="
Cancel-Lock: sha1:MwwTVKRZyXH6uMtZrQeB7vBWrUI=
X-Newsreader: Forte Free Agent 1.93/32.576 English (American)
View all headers

On Mon, 17 Jun 2024 08:08:07 +0200, Janis Papanagnou
<janis_papanagnou+ng@hotmail.com> wrote:

>In a recent thread realloc() was a substantial part of the discussion.
>"Occasionally" the increased data storage will be relocated along
>with the previously stored data. On huge data sets that might be a
>performance factor. Is there any experience or are there any concrete
>factors about the conditions when this relocation happens? - I could
>imagine that it's no issue as long as you're in some kB buffer range,
>but if, say, we're using realloc() to substantially increase buffers
>often it might be an issue to consider. It would be good to get some
>feeling about that internal.
>
>Janis

the only problem i see it is the memory that is free is the first has
to be used, or be returned from malloc or realloc, because that memory
is already in a good position near the cpu

Subject: Re: realloc() - frequency, conditions, or experiences about relocation?
From: Malcolm McLean
Newsgroups: comp.lang.c
Organization: A noiseless patient Spider
Date: Tue, 18 Jun 2024 10:19 UTC
References: 1 2 3 4 5 6 7 8
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: malcolm.arthur.mclean@gmail.com (Malcolm McLean)
Newsgroups: comp.lang.c
Subject: Re: realloc() - frequency, conditions, or experiences about
relocation?
Date: Tue, 18 Jun 2024 11:19:12 +0100
Organization: A noiseless patient Spider
Lines: 88
Message-ID: <v4rmv0$19t6u$1@dont-email.me>
References: <v4ojs8$gvji$1@dont-email.me> <875xu8vsen.fsf@bsb.me.uk>
<v4ovqf$j5hq$1@dont-email.me> <87zfrjvqp6.fsf@bsb.me.uk>
<v4pb4v$lhgk$1@dont-email.me> <87tthrvdtg.fsf@bsb.me.uk>
<20240617181034.74fb4cca1f4a9a3ea032825e@g{oogle}mail.com>
<86r0cuk9qz.fsf@linuxsc.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 18 Jun 2024 12:19:12 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="cba6eb24be5a0db449e57ccf4e727e7c";
logging-data="1373406"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19UZG1UCIEXrTNbEjT9HWSOm68eNqN9pAU="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:dZT0jPGGjgFswRrr7t4bzNqTzi4=
In-Reply-To: <86r0cuk9qz.fsf@linuxsc.com>
Content-Language: en-GB
View all headers

On 18/06/2024 08:09, Tim Rentsch wrote:
> Anton Shepelev <anton.txt@g{oogle}mail.com> writes:
>
>> Ben Bacarisse to Malcolm McLean:
>>
>>> [next is a comment from Malcolm]
>>>
>>>> Your strategy for avoiding these extremes is exponential
>>>> growth.
>>>
>>> It's odd to call it mine. It's very widely know and used.
>>> "The one I mentioned" might be less confusing description.
>>
>> I think it is a modern English idiom, which I dislike as
>> well. StackOverflow is full of questions starting like:
>> "How do you do this?" and "How do I do that?" They are
>> informal ways of the more literary "How does one do this?"
>> or "What is the way to do that?"
>
> I have a different take here. First the "your" of "your
> strategy" reads as a definite pronoun, meaning it refers
> specifically to Ben and not to some unknown other party.
> (And incidentally is subtly insulting because of that,
> whether it was meant that way or not.)
>
> Second the use of "you" to mean an unspecified other person
> is not idiom but standard usage. The word "you" is both a
> definite pronoun and an indefinite pronoun, depending on
> context. The word "they" also has this property. Consider
> these two examples:
>
> The bank downtown was robbed. They haven't been caught
> yet.
>
> They say the sheriff isn't going to run for re-election.
>
> In the first example "they" is a definite pronoun, referring
> to the people who robbed the bank. In the second example,
> "they" is an indefinite pronoun, referring to unspecified
> people in general (perhaps but not necessarily everyone).
> The word "you" is similar: it can mean specifically the
> listener, or it can mean generically anyone in a broader
> audience, even those who never hear or read the statement
> with "you" in it.
>
> The word "one" used as a pronoun is more formal, and to me
> at least often sounds stilted. In US English "one" is most
> often an indefinite pronoun, either second person or third
> person. But "one" can also be used as a first person
> definite pronoun (referring to the speaker), which an online
> reference tells me is chiefly British English. (I would
> guess that this usage predominates in "the Queen's English"
> dialect of English, but I have very little experience in
> such things.)
>
> Finally I would normally read "I" as a first person definite
> pronoun, and not an indefinite pronoun. So I don't have any
> problem with someone saying "how should I ..." when asking
> for advice. They aren't asking how someone else should ...
> but how they should ..., and what advice I might give could
> very well depend on who is doing the asking.

Ben said
> Restore snipped Ben upthread
"In practice, the cost is usually
moderate and can be very effectively managed by using an exponential
allocation scheme: at every reallocation multiply the storage space by
some factor greater than 1 (I often use 3/2, but doubling is often used
as well)."

So it's open and shut, and no two ways about it. Ben's strategy is
exponential growth. And to be fair I use that strategy myself in
functions like fslutp(). It's only not Ben's strategy if we mean to
imply that Ben was the first person to use expoential growth, or the
first to understand the mathematical implications, and of course that's
not the case. It was all worked out by Euler long before any of us were
born.

The question is whether we can be a bit more rigorous than "we need
exonential growth, let's double on each reallocation. Actually, that
looks a bit greedy. Try 3/2". And we can do that. We can put it on a
sounder statistical footing. Whether it actually worth it or not is a
different matter.

--
Check out my hobby project.
http://malcolmmclean.github.io/babyxrc

Subject: Re: realloc() - frequency, conditions, or experiences about relocation?
From: Malcolm McLean
Newsgroups: comp.lang.c
Organization: A noiseless patient Spider
Date: Tue, 18 Jun 2024 10:46 UTC
References: 1 2 3 4 5 6 7 8 9
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: malcolm.arthur.mclean@gmail.com (Malcolm McLean)
Newsgroups: comp.lang.c
Subject: Re: realloc() - frequency, conditions, or experiences about
relocation?
Date: Tue, 18 Jun 2024 11:46:36 +0100
Organization: A noiseless patient Spider
Lines: 101
Message-ID: <v4roic$1ad0g$1@dont-email.me>
References: <v4ojs8$gvji$1@dont-email.me> <875xu8vsen.fsf@bsb.me.uk>
<v4ovqf$j5hq$1@dont-email.me> <87zfrjvqp6.fsf@bsb.me.uk>
<v4pb4v$lhgk$1@dont-email.me> <87tthrvdtg.fsf@bsb.me.uk>
<20240617181034.74fb4cca1f4a9a3ea032825e@g{oogle}mail.com>
<86r0cuk9qz.fsf@linuxsc.com> <v4rmv0$19t6u$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Tue, 18 Jun 2024 12:46:37 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="cba6eb24be5a0db449e57ccf4e727e7c";
logging-data="1389584"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+xig82jv+nLSfger+LqjX8rHju0/1maNQ="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:I0P4GNBviDuYPLQ7koFSqlYSQdg=
Content-Language: en-GB
In-Reply-To: <v4rmv0$19t6u$1@dont-email.me>
View all headers

On 18/06/2024 11:19, Malcolm McLean wrote:
> On 18/06/2024 08:09, Tim Rentsch wrote:
>> Anton Shepelev <anton.txt@g{oogle}mail.com> writes:
>>
>>> Ben Bacarisse to Malcolm McLean:
>>>
>>>> [next is a comment from Malcolm]
>>>>
>>>>> Your strategy for avoiding these extremes is exponential
>>>>> growth.
>>>>
>>>> It's odd to call it mine.  It's very widely know and used.
>>>> "The one I mentioned" might be less confusing description.
>>>
>>> I think it is a modern English idiom, which I dislike as
>>> well.  StackOverflow is full of questions starting like:
>>> "How do you do this?" and "How do I do that?"  They are
>>> informal ways of the more literary "How does one do this?"
>>> or "What is the way to do that?"
>>
>> I have a different take here.  First the "your" of "your
>> strategy" reads as a definite pronoun, meaning it refers
>> specifically to Ben and not to some unknown other party.
>> (And incidentally is subtly insulting because of that,
>> whether it was meant that way or not.)
>>
>> Second the use of "you" to mean an unspecified other person
>> is not idiom but standard usage.  The word "you" is both a
>> definite pronoun and an indefinite pronoun, depending on
>> context.  The word "they" also has this property.  Consider
>> these two examples:
>>
>>     The bank downtown was robbed.  They haven't been caught
>>     yet.
>>
>>     They say the sheriff isn't going to run for re-election.
>>
>> In the first example "they" is a definite pronoun, referring
>> to the people who robbed the bank.  In the second example,
>> "they" is an indefinite pronoun, referring to unspecified
>> people in general (perhaps but not necessarily everyone).
>> The word "you" is similar:  it can mean specifically the
>> listener, or it can mean generically anyone in a broader
>> audience, even those who never hear or read the statement
>> with "you" in it.
>>
>> The word "one" used as a pronoun is more formal, and to me
>> at least often sounds stilted.  In US English "one" is most
>> often an indefinite pronoun, either second person or third
>> person.  But "one" can also be used as a first person
>> definite pronoun (referring to the speaker), which an online
>> reference tells me is chiefly British English.  (I would
>> guess that this usage predominates in "the Queen's English"
>> dialect of English, but I have very little experience in
>> such things.)
>>
>> Finally I would normally read "I" as a first person definite
>> pronoun, and not an indefinite pronoun.  So I don't have any
>> problem with someone saying "how should I ..." when asking
>> for advice.  They aren't asking how someone else should ...
>> but how they should ..., and what advice I might give could
>> very well depend on who is doing the asking.
>
> Ben said
> > Restore snipped Ben upthread
> "In practice, the cost is usually
> moderate and can be very effectively managed by using an exponential
> allocation scheme: at every reallocation multiply the storage space by
> some factor greater than 1 (I often use 3/2, but doubling is often used
> as well)."
>
> So it's open and shut, and no two ways about it. Ben's strategy is
> exponential growth. And to be fair I use that strategy myself in
> functions like fslutp(). It's only not Ben's strategy if we mean to
> imply that Ben was the first person to use expoential growth, or the
> first to understand the mathematical implications, and of course that's
> not the case. It was all worked out by Euler long before any of us were
> born.
>
> The question is whether we can be a bit more rigorous than "we need
> exonential growth, let's double on each reallocation. Actually, that
> looks a bit greedy. Try 3/2". And we can do that. We can put it on a
> sounder statistical footing. Whether it actually worth it or not is a
> different matter.
>
Here are some real stats on file sizes, in case anone is interested.

Data set, / OS Log-normal median & mean, Arithmetic mean, 50% occupied by
(< mean)

whole data set, 9.0 KB, 730 KB, 1.5 MB < 5.4 KB
Mac OS 8.0 KB, 533 KB, 1.4 MB < 4.9 KB
Windows 11.5 KB, 1.0 MB, 1.7 MB < 8.3 KB
GNU/Linux 10.8 KB, 1.7MB, 2.2 MB < 4.8 KB

https://www.researchgate.net/publication/353066615_How_Big_Are_Peoples%27_Computer_Files_File_Size_Distributions_Among_User-managed_Collections

--
Check out my hobby project.
http://malcolmmclean.github.io/babyxrc

Subject: Re: realloc() - frequency, conditions, or experiences about relocation?
From: David Jones
Newsgroups: comp.lang.c, sci.stat.math
Organization: A noiseless patient Spider
Date: Tue, 18 Jun 2024 17:59 UTC
References: 1 2 3 4 5 6
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: dajhawk18xx@@nowhere.com (David Jones)
Newsgroups: comp.lang.c,sci.stat.math
Subject: Re: realloc() - frequency, conditions, or experiences about relocation?
Date: Tue, 18 Jun 2024 17:59:30 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 59
Message-ID: <v4shu2$1ff4q$1@dont-email.me>
References: <v4ojs8$gvji$1@dont-email.me> <875xu8vsen.fsf@bsb.me.uk> <v4ovqf$j5hq$1@dont-email.me> <87zfrjvqp6.fsf@bsb.me.uk> <v4pb4v$lhgk$1@dont-email.me> <20240617180249.96dfaafa89392827aa162434@g{oogle}mail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 18 Jun 2024 19:59:30 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="f1972676a64567a0e5798bf903aaf93f";
logging-data="1555610"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX183Zu22dBRgeZCLTcCVptp8ugJ709ON/2w="
User-Agent: XanaNews/1.21-f3fb89f (x86; Portable ISpell)
Cancel-Lock: sha1:CX4WAHFVXGgckqNjjrB3VfpbDD4=
View all headers

Anton Shepelev wrote:

> [cross-posted to: ci.stat.math]
>
> Malcolm McLean:
>
> > We have a continuously growing buffer, and we want the
> > best strategy for reallocations as the stream of
> > characters comes at us. So, given we now how many
> > characters have arrived, can we predict how many will
> > arrive,
>
> Do you mean in the next bunch, or in total (till the end of
> the buffer's lifetime)?
>
> > and therefore ask for the best amount when we reallocate,
> > so that we neither make too many reallocation (reallocate
> > on every byte received) or ask for too much (demand
> > SIZE_MAX memory when the first byte is received).?
> >
> > Your strategy for avoiding these extremes is exponential
> > growth. You allocate a small amount for the first few
> > bytes. Then you use exponential growth, with a factor of
> > ether 2 or 1.5.
>
> This strategy ensures a constant ratio between the amount of
> reallocated data to the length of the buffer by making
> reallocations less frequent as the buffer grows.
>
> > And so we integrate the distribution between the point we
> > are at and infinity. Then we tkae the mean. And that gives
> > us a best estimate of how many bytes are to come, and
> > therefore how much to grow the buffer by.
>
> You have an apriori distribution of the buffer size (can be
> tracked on-the-fly, if unknown beforehand) and a partially
> filled buffer. The task is to calculate the a-posteriori
> distribution of that buffer's final size, and then to
> allocate the predicted value based on a good percentile.
>
> How about using a percentile instead of the mean, e.g. if
> the current size corresponds to percentile p, you allocate a
> capacity corresponding to percentile 1-(1-p)/k , where k>1
> denotes the balance between space and time efficency. For
> example, if the 60th percentile of the buffer is required
> and k=2, you allocate a capacity sufficient to hold
> 100-(100-60)/2=80% of buffers.

Based on essentially no background to this question, not much can be
said. However, if one starts from the suggestion above to use the mean
of some distribution (or later some percentile), one notes that the
"mean" is just the minimum of a quadratic cast function ,,, so an
improvement would be to base the choice on some more realistic cost
function, chosen for the actual application. Given that the scenario
apparently involves a sequence of such decisions, the obvious extension
of the cost-based approach would be to employ some form of dynamic
programming. Of course, this might not be appealing, in which case one
might choose the theoretically-simple approach of tuning a policy based
on good stchastic simulations of the situation.

Subject: Re: realloc() - frequency, conditions, or experiences about relocation?
From: David Duffy
Newsgroups: comp.lang.c, sci.stat.math
Organization: A noiseless patient Spider
Date: Wed, 19 Jun 2024 06:48 UTC
References: 1 2 3 4 5 6
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: davidd02@tpg.com.au (David Duffy)
Newsgroups: comp.lang.c,sci.stat.math
Subject: Re: realloc() - frequency, conditions, or experiences about relocation?
Date: Wed, 19 Jun 2024 06:48:17 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 23
Message-ID: <v4tuvf$1qto5$1@dont-email.me>
References: <v4ojs8$gvji$1@dont-email.me> <875xu8vsen.fsf@bsb.me.uk> <v4ovqf$j5hq$1@dont-email.me> <87zfrjvqp6.fsf@bsb.me.uk> <v4pb4v$lhgk$1@dont-email.me> <20240617180249.96dfaafa89392827aa162434@g{oogle}mail.com>
Injection-Date: Wed, 19 Jun 2024 08:48:17 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="31d8f887133f0f81d700803c97977601";
logging-data="1931013"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19y0qBGbwcBYZ9zEnccmGyzc2qWwMSSv8M="
User-Agent: tin/2.6.2-20220130 ("Convalmore") (Linux/5.15.0-112-generic (x86_64))
Cancel-Lock: sha1:Ufn1u77c+t57vdkhPzXMhxcM/L8=
View all headers

In sci.stat.math Anton Shepelev <anton.txt@g{oogle}mail.com> wrote:
> [cross-posted to: ci.stat.math]
>
> Malcolm McLean:
>
>> We have a continuously growing buffer, and we want the
>> best strategy for reallocations as the stream of
>> characters comes at us. So, given we now how many
>> characters have arrived, can we predict how many will
>> arrive,
>
> Do you mean in the next bunch, or in total (till the end of
> the buffer's lifetime)?
>
Isn't this a halting problem? Aren't the more important data:
how much memory the user is allowed to allocate, the properties of
the current system's memory allocation algorithm, when your stream
will have to go to disc or other slow large volume storage, how
the stream can be compressed on the fly (the latter might well give
strong predictions for future storage requirements based on what
has been read to date).

Subject: Re: realloc() - frequency, conditions, or experiences about relocation?
From: Malcolm McLean
Newsgroups: comp.lang.c, sci.stat.math
Organization: A noiseless patient Spider
Date: Wed, 19 Jun 2024 09:12 UTC
References: 1 2 3 4 5 6 7
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: malcolm.arthur.mclean@gmail.com (Malcolm McLean)
Newsgroups: comp.lang.c,sci.stat.math
Subject: Re: realloc() - frequency, conditions, or experiences about
relocation?
Date: Wed, 19 Jun 2024 10:12:22 +0100
Organization: A noiseless patient Spider
Lines: 39
Message-ID: <v4u7dm$1t2pu$1@dont-email.me>
References: <v4ojs8$gvji$1@dont-email.me> <875xu8vsen.fsf@bsb.me.uk>
<v4ovqf$j5hq$1@dont-email.me> <87zfrjvqp6.fsf@bsb.me.uk>
<v4pb4v$lhgk$1@dont-email.me>
<20240617180249.96dfaafa89392827aa162434@g{oogle}mail.com>
<v4tuvf$1qto5$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Wed, 19 Jun 2024 11:12:23 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="1546666429f4a47bce7f01cf2bfd5cd4";
logging-data="2001726"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+NhKgLD0FcTDGgR5+7heC7SHMxQ6FYSqU="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:JSfB+/4sculAWbh+xnh7XpL0sik=
Content-Language: en-GB
In-Reply-To: <v4tuvf$1qto5$1@dont-email.me>
View all headers

On 19/06/2024 07:48, David Duffy wrote:
> In sci.stat.math Anton Shepelev <anton.txt@g{oogle}mail.com> wrote:
>> [cross-posted to: ci.stat.math]
>>
>> Malcolm McLean:
>>
>>> We have a continuously growing buffer, and we want the
>>> best strategy for reallocations as the stream of
>>> characters comes at us. So, given we now how many
>>> characters have arrived, can we predict how many will
>>> arrive,
>>
>> Do you mean in the next bunch, or in total (till the end of
>> the buffer's lifetime)?
>>
> Isn't this a halting problem? Aren't the more important data:
> how much memory the user is allowed to allocate, the properties of
> the current system's memory allocation algorithm, when your stream
> will have to go to disc or other slow large volume storage, how
> the stream can be compressed on the fly (the latter might well give
> strong predictions for future storage requirements based on what
> has been read to date).
>
>
No. We have to have some knowledge. And what we probaby know is that the
input is a file stored on someone's personal computer. And someone has
published on the statistical distribution of such files And they have a
log-normal distribution with a mean and a median which he gives. So with
that informaton, we can work out, given that a file is at least N
characters, what is the prbablity that an allocation of any size will
contain the whole file, and how many bytes, on average will be wasted.

Statistical analysis can't tell us what a allocation wil cost versus the
cost of hoggng memory we don't need, however. It can;t tell us what to
do. Just put us in the picture.
--
Check out my hobby project.
http://malcolmmclean.github.io/babyxrc

Subject: Re: realloc() - frequency, conditions, or experiences about relocation?
From: Anton Shepelev
Newsgroups: comp.lang.c, sci.stat.math
Organization: A noiseless patient Spider
Date: Wed, 19 Jun 2024 12:20 UTC
References: 1 2 3 4 5 6 7
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: anton.txt@g{oogle}mail.com (Anton Shepelev)
Newsgroups: comp.lang.c,sci.stat.math
Subject: Re: realloc() - frequency, conditions, or experiences about
relocation?
Date: Wed, 19 Jun 2024 15:20:00 +0300
Organization: A noiseless patient Spider
Lines: 35
Message-ID: <20240619152000.2738defeceb1df7203151c64@g{oogle}mail.com>
References: <v4ojs8$gvji$1@dont-email.me>
<875xu8vsen.fsf@bsb.me.uk>
<v4ovqf$j5hq$1@dont-email.me>
<87zfrjvqp6.fsf@bsb.me.uk>
<v4pb4v$lhgk$1@dont-email.me>
<20240617180249.96dfaafa89392827aa162434@g{oogle}mail.com>
<v4tuvf$1qto5$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Injection-Date: Wed, 19 Jun 2024 14:20:01 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="026ce8aa09340af2ff7fb15fc26bc16e";
logging-data="2030938"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+ND7OP8LQtEeJgm0gAIn4VUlpZD7fyRyY="
Cancel-Lock: sha1:nbNA+JHvknkLzu1lhi4p3NOjeQc=
X-Newsreader: Sylpheed 3.7.0 (GTK+ 2.24.30; i686-pc-mingw32)
View all headers

Malcolm McLean writes that, given the log-normal distribution
of file sizes with known parameters,

> we can work out, given that a file is at least N
> characters, what is the prbablity that an allocation of
> any size will contain the whole file, and how many bytes,
> on average will be wasted.

This is why I thought statisticians might help him: Malcolm
wants to find the aposteriori distribution of the size of a
file, after it has been found to exceed N bytes. Am I right
that if we take the remaining (N>20) part of the density
function and re-normalise it, we shall obtain the desired
distribution?

My proposition was as follows:

1. Find quantile q0 corresponding to the buffer size
currently requested.

2. Calculate new quantile q1 = 1-(1-q0)/k, where k>1 is
an adjustable parameter, and use its corresponding
value as the new allocation size.

For example, assuming for simplicity a uniform [0,20]
distribution of file sizez and k=2, a sequence of allocation
may look like this:

requested allocated
2 20-(20- 2)/2 = 11
12 20-(20-12)/2 = 16
18 20-(20-18)/2 = 19
--
() ascii ribbon campaign -- against html e-mail
/\ www.asciiribbon.org -- against proprietary attachments

Subject: Re: realloc() - frequency, conditions, or experiences about relocation?
From: Ben Bacarisse
Newsgroups: comp.lang.c, sci.stat.math
Organization: A noiseless patient Spider
Date: Wed, 19 Jun 2024 15:36 UTC
References: 1 2 3 4 5 6 7 8
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: ben@bsb.me.uk (Ben Bacarisse)
Newsgroups: comp.lang.c,sci.stat.math
Subject: Re: realloc() - frequency, conditions, or experiences about relocation?
Date: Wed, 19 Jun 2024 16:36:01 +0100
Organization: A noiseless patient Spider
Lines: 17
Message-ID: <875xu5t066.fsf@bsb.me.uk>
References: <v4ojs8$gvji$1@dont-email.me> <875xu8vsen.fsf@bsb.me.uk>
<v4ovqf$j5hq$1@dont-email.me> <87zfrjvqp6.fsf@bsb.me.uk>
<v4pb4v$lhgk$1@dont-email.me>
<20240617180249.96dfaafa89392827aa162434@g{oogle}mail.com>
<v4tuvf$1qto5$1@dont-email.me> <v4u7dm$1t2pu$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Date: Wed, 19 Jun 2024 17:36:15 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="82406a6777ea81192be6ede1e900a6d7";
logging-data="2143113"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/eocK1G7S/3nQc0spIjgJVW6wN/NXxlns="
User-Agent: Gnus/5.13 (Gnus v5.13)
Cancel-Lock: sha1:ZWZ+q9UZ4yXQBPKyZMjemsx50Z4=
sha1:vLEz1eZfy3s262RV5hbxlSZnREM=
X-BSB-Auth: 1.98397e6bd73b7eb51b08.20240619163601BST.875xu5t066.fsf@bsb.me.uk
View all headers

Malcolm McLean <malcolm.arthur.mclean@gmail.com> writes:

> No. We have to have some knowledge. And what we probaby know is that the
> input is a file stored on someone's personal computer. And someone has
> published on the statistical distribution of such files

That's not the case that matters (to me at least). If the input is a
file, we have a much better way of "guessing" the size than guessing and
growing -- just ask for the size. Sure, we might need to make
adjustments if the file is changing, but there is always a better
measure than any statistical analysis.

To some extent this seems like a solution in search of a problem.
Growing the buffer exponentially is simple and effective.

--
Ben.

Subject: Re: realloc() - frequency, conditions, or experiences about relocation?
From: David Brown
Newsgroups: comp.lang.c, sci.stat.math
Organization: A noiseless patient Spider
Date: Wed, 19 Jun 2024 17:41 UTC
References: 1 2 3 4 5 6 7 8 9
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: david.brown@hesbynett.no (David Brown)
Newsgroups: comp.lang.c,sci.stat.math
Subject: Re: realloc() - frequency, conditions, or experiences about
relocation?
Date: Wed, 19 Jun 2024 19:41:49 +0200
Organization: A noiseless patient Spider
Lines: 42
Message-ID: <v4v58t$230rh$1@dont-email.me>
References: <v4ojs8$gvji$1@dont-email.me> <875xu8vsen.fsf@bsb.me.uk>
<v4ovqf$j5hq$1@dont-email.me> <87zfrjvqp6.fsf@bsb.me.uk>
<v4pb4v$lhgk$1@dont-email.me>
<20240617180249.96dfaafa89392827aa162434@g{oogle}mail.com>
<v4tuvf$1qto5$1@dont-email.me> <v4u7dm$1t2pu$1@dont-email.me>
<875xu5t066.fsf@bsb.me.uk>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Wed, 19 Jun 2024 19:41:49 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="496e798c2f4d7717891a7779c6d418c6";
logging-data="2196337"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+doEZ1BuKX138+9PzKwHPN0j+0ZbYsBcc="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
Thunderbird/102.11.0
Cancel-Lock: sha1:XziIqipJUSn9Yw42qwBC83cPZwc=
In-Reply-To: <875xu5t066.fsf@bsb.me.uk>
Content-Language: en-GB
View all headers

On 19/06/2024 17:36, Ben Bacarisse wrote:
> Malcolm McLean <malcolm.arthur.mclean@gmail.com> writes:
>
>> No. We have to have some knowledge. And what we probaby know is that the
>> input is a file stored on someone's personal computer. And someone has
>> published on the statistical distribution of such files
>
> That's not the case that matters (to me at least). If the input is a
> file, we have a much better way of "guessing" the size than guessing and
> growing -- just ask for the size. Sure, we might need to make
> adjustments if the file is changing, but there is always a better
> measure than any statistical analysis.
>
> To some extent this seems like a solution in search of a problem.

It seems more like a solution that doesn't exist in search of a problem
with absurdly unrealistic requirements. And even if Malcolm's solution
existed, and the problem existed, it /still/ wouldn't work - knowing the
distribution of file sizes tells us nothing about the size of any given
file.

> Growing the buffer exponentially is simple and effective.
>

Yes, that's the general way to handle buffers when you don't know what
size they should be.

A better solutions for this sort of program is usually, as you say,
asking the OS for the file size (there is no standard library function
for getting the file size, but it's not hard to do for any realistic
target OS). And then for big files, prefer mmap to reading the file
into a buffer.

It's only really for unsized "files" such as piped input that you have
no way of getting the size, and then exponential growth is the way to
go. Personally, I'd start with a big size (perhaps 10 MB) that is
bigger than you are likely to need in practice, but small enough that it
is negligible on even vaguely modern computers. Then the realloc code is
unlikely to be used (but it can still be there for completeness).

Subject: Re: realloc() - frequency, conditions, or experiences about relocation?
From: Ben Bacarisse
Newsgroups: comp.lang.c, sci.stat.math
Followup: comp.lang.c
Organization: A noiseless patient Spider
Date: Wed, 19 Jun 2024 21:24 UTC
References: 1 2 3 4 5 6 7 8 9 10
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: ben@bsb.me.uk (Ben Bacarisse)
Newsgroups: comp.lang.c,sci.stat.math
Subject: Re: realloc() - frequency, conditions, or experiences about relocation?
Followup-To: comp.lang.c
Date: Wed, 19 Jun 2024 22:24:35 +0100
Organization: A noiseless patient Spider
Lines: 28
Message-ID: <87o77wsk18.fsf@bsb.me.uk>
References: <v4ojs8$gvji$1@dont-email.me> <875xu8vsen.fsf@bsb.me.uk>
<v4ovqf$j5hq$1@dont-email.me> <87zfrjvqp6.fsf@bsb.me.uk>
<v4pb4v$lhgk$1@dont-email.me>
<20240617180249.96dfaafa89392827aa162434@g{oogle}mail.com>
<v4tuvf$1qto5$1@dont-email.me> <v4u7dm$1t2pu$1@dont-email.me>
<875xu5t066.fsf@bsb.me.uk> <v4v58t$230rh$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Date: Wed, 19 Jun 2024 23:24:37 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="82406a6777ea81192be6ede1e900a6d7";
logging-data="2283713"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18/33B1VRjgpiPoVRYp/T7JgUKClchVBC8="
User-Agent: Gnus/5.13 (Gnus v5.13)
Cancel-Lock: sha1:zNH5OGRHLayATjshiPlEL0N/+Io=
sha1:FcbLbN42sMnCe47MJP8k+0Adcuc=
X-BSB-Auth: 1.a85571cc43e4f6b382c3.20240619222435BST.87o77wsk18.fsf@bsb.me.uk
View all headers

David Brown <david.brown@hesbynett.no> writes:

> On 19/06/2024 17:36, Ben Bacarisse wrote:
>> Growing the buffer exponentially is simple and effective.
>
> Yes, that's the general way to handle buffers when you don't know what size
> they should be.
>
> A better solutions for this sort of program is usually, as you say, asking
> the OS for the file size (there is no standard library function for getting
> the file size, but it's not hard to do for any realistic target OS). And
> then for big files, prefer mmap to reading the file into a buffer.
>
> It's only really for unsized "files" such as piped input that you have no
> way of getting the size, and then exponential growth is the way to go.
> Personally, I'd start with a big size (perhaps 10 MB) that is bigger than
> you are likely to need in practice, but small enough that it is negligible
> on even vaguely modern computers. Then the realloc code is unlikely to be
> used (but it can still be there for completeness).

There are other uses that have nothing to do with files. I have a small
dynamic array library (just a couple of function) that I use for all
sorts of things. I can read a file or parse tokens or input a line just
by adding characters. Because of its rather general use, I don't start
with a large buffer (though the initial size can be set).

--
Ben.

Subject: Re: realloc() - frequency, conditions, or experiences about relocation?
From: Anton Shepelev
Newsgroups: comp.lang.c, sci.stat.math
Organization: A noiseless patient Spider
Date: Wed, 19 Jun 2024 22:53 UTC
References: 1 2 3 4 5 6 7 8
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: anton.txt@gmail.moc (Anton Shepelev)
Newsgroups: comp.lang.c,sci.stat.math
Subject: Re: realloc() - frequency, conditions, or experiences about
relocation?
Date: Thu, 20 Jun 2024 01:53:47 +0300
Organization: A noiseless patient Spider
Lines: 44
Message-ID: <20240620015347.9bdcc4df03ab63d096375450@gmail.moc>
References: <v4ojs8$gvji$1@dont-email.me>
<875xu8vsen.fsf@bsb.me.uk>
<v4ovqf$j5hq$1@dont-email.me>
<87zfrjvqp6.fsf@bsb.me.uk>
<v4pb4v$lhgk$1@dont-email.me>
<20240617180249.96dfaafa89392827aa162434@g{oogle}mail.com>
<v4tuvf$1qto5$1@dont-email.me>
<v4u7dm$1t2pu$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 20 Jun 2024 00:53:49 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="b394b4f438bd83bf46fe16e962fd5edb";
logging-data="2318502"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/r1HnWRqgy24DdnETNx71smiLltbSz8lM="
Cancel-Lock: sha1:LE8/zn1c9L7SSeuTU5M4augVWi0=
X-Newsreader: Sylpheed 3.7.0 (GTK+ 2.24.30; i686-pc-mingw32)
View all headers

Malcolm McLean:

> We have to have some knowledge. And what we probaby know
> is that the input is a file stored on someone's personal
> computer. And someone has published on the statistical
> distribution of such files And they have a log-normal
> distribution with a mean and a median which he gives. So
> with that informaton, we can work out, given that a file
> is at least N characters, what is the prbablity that an
> allocation of any size will contain the whole file, and
> how many bytes, on average will be wasted.

Observe that the standard algorithm of exponential growth is
memoryless and self-similar in that in does not depend on
context, or the history of previous reallocations. These
properties belong to (or even identify?) the exponential
distribution. We can therefore assume that exponential-
growth strategy is ideal for exponentially distributed
buffer sizes, and under that assumption determine the
relation between the CDF values (p) corresponding to
consequent re-allcoations:

p = e^x/L ,
p0 = 1-e^(L*x0) ,
p1 = 1-e^(L*x1) ,
x1 = k*x0 (by our strategy), =>
p1 = 1-(1-p0)^k .

which does not depend on the distribution and lets us
generalise this approach for any distribution:

x1 = Q( 1 - ( 1 - CDF(x0) )^k )

where:

x0 : the required size
x1 : the new recommended capacity
Q(p) : the p-Quantile of the given distribution
CDF(x): the CDF of the given distribution
k>1 : balance between speed and space efficiency

--
() ascii ribbon campaign -- against html e-mail
/\ www.asciiribbon.org -- against proprietary attachments

Subject: Indefinite pronouns [was:Re: realloc() - frequency, conditions, or experiences about relocation?]
From: Anton Shepelev
Newsgroups: comp.lang.c, alt.english.usage
Organization: A noiseless patient Spider
Date: Wed, 19 Jun 2024 23:51 UTC
References: 1 2 3 4 5 6 7 8
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: anton.txt@gmail.moc (Anton Shepelev)
Newsgroups: comp.lang.c,alt.english.usage
Subject: Indefinite pronouns [was:Re: realloc() - frequency, conditions, or
experiences about relocation?]
Date: Thu, 20 Jun 2024 02:51:56 +0300
Organization: A noiseless patient Spider
Lines: 109
Message-ID: <20240620025156.2ae9300726603b4cb3631547@gmail.moc>
References: <v4ojs8$gvji$1@dont-email.me>
<875xu8vsen.fsf@bsb.me.uk>
<v4ovqf$j5hq$1@dont-email.me>
<87zfrjvqp6.fsf@bsb.me.uk>
<v4pb4v$lhgk$1@dont-email.me>
<87tthrvdtg.fsf@bsb.me.uk>
<20240617181034.74fb4cca1f4a9a3ea032825e@g{oogle}mail.com>
<86r0cuk9qz.fsf@linuxsc.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 20 Jun 2024 01:51:56 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="b394b4f438bd83bf46fe16e962fd5edb";
logging-data="2337038"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+J+uW4EttliUeRwmKKFW25xk9YI0Wnc+o="
Cancel-Lock: sha1:Xmw8BnwCYITDiUcSxEX93ZVNbiw=
X-Newsreader: Sylpheed 3.7.0 (GTK+ 2.24.30; i686-pc-mingw32)
View all headers

Cross-posting to alt.english.usage .

Tim Rentsch to Anton Shepelev:

> > I think it is a modern English idiom, which I dislike as
> > well. StackOverflow is full of questions starting like:
> > "How do you do this?" and "How do I do that?" They are
> > informal ways of the more literary "How does one do
> > this?" or "What is the way to do that?"
>
> I have a different take here. First the "your" of "your
> strategy" reads as a definite pronoun, meaning it refers
> specifically to Ben and not to some unknown other party.

And I am /sure/ it is intended in the general (indefinite)
sense, as is the `you' in Malcolm's two following sentences:

> You allocate a small amount for the first few bytes. Then
> you use exponential growth, with a factor of ether 2 or
> 1.5.

This is the typical wording of impersonal instruction in
modern English.

> (And incidentally is subtly insulting because of that,
> whether it was meant that way or not.)

Yes! My first impulse is always to interpret those pronouns
according to their literal (definite) meanings, which gives
the text an insulting (because presumptuos) taint. This is
why I wince at the indefinite useage of first- and second-
person pronouns.

> Second the use of "you" to mean an unspecified other
> person is not idiom but standard usage.

`Idiomatic' can mean `standard':

Of or pertaining to, or conforming to, the mode of
expression peculiar to a language; as, an idiomatic
meaning; an idiomatic phrase.

> The word "you" is both a definite pronoun and an
> indefinite pronoun, depending on context.

It /is/ used as in indefinite pronoun, is not widely
recognised as capable of that function:

https://eslgrammar.org/indefinite-pronouns/
https://dictionary.cambridge.org/grammar/british-grammar/indefinite-pronouns

And when it is, only as an informal relaxation:

https://www.englishclub.com/grammar/pronouns-indefinite.php

These recent informal usages can be ugly.

> The word "they" also has this property.

I know it, and agree:

They took some honey from a tree,
Dressed it up and then called it me.
<https://on.soundcloud.com/NGz7nZgzm4hiQQbd6>

The indefinite `they' can be used formally as well.

> The word "you" is similar: it can mean specifically the
> listener, or it can mean generically anyone in a broader
> audience, even those who never hear or read the statement
> with "you" in it.

Modern teenagers definitely see it that way, and I have to
clench my teech and adapt.

> The word "one" used as a pronoun is more formal, and to me
> at least often sounds stilted. In US English "one" is
> most often an indefinite pronoun, either second person or
> third person.

How can it be a second-person pronoun? The famous phrase
"One never knows, do one?" features a third-person `one'
with a dialectical third-person `do'.

> But "one" can also be used as a first person definite
> pronoun (referring to the speaker), which an online
> reference tells me is chiefly British English.

I had no idea it could, nor does Wikipedia. Can you share
an example of a definite first-person `one'?

> Finally I would normally read "I" as a first person
> definite pronoun, and not an indefinite pronoun.

And so would I, and I hate the indefinte usage.

> So I don't have any problem with someone saying "how
> should I ..." when asking for advice. They aren't asking
> how someone else should ... but how they should ..., and
> what advice I might give could very well depend on who is
> doing the asking.

The problem is, in 99% of cases no personal information is
given that could possibly justify the personal wording of
the question.

--
() ascii ribbon campaign -- against html e-mail
/\ www.asciiribbon.org -- against proprietary attachments

Subject: Re: Indefinite pronouns
From: vallor
Newsgroups: comp.lang.c, alt.english.usage
Followup: alt.english.usage
Organization: A noiseless patient Spider
Date: Thu, 20 Jun 2024 00:34 UTC
References: 1 2 3 4 5 6 7 8 9
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: vallor@cultnix.org (vallor)
Newsgroups: comp.lang.c,alt.english.usage
Subject: Re: Indefinite pronouns
Followup-To: alt.english.usage
Date: Thu, 20 Jun 2024 00:34:43 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 25
Message-ID: <v4vtf3$27bok$1@dont-email.me>
References: <v4ojs8$gvji$1@dont-email.me> <875xu8vsen.fsf@bsb.me.uk>
<v4ovqf$j5hq$1@dont-email.me> <87zfrjvqp6.fsf@bsb.me.uk>
<v4pb4v$lhgk$1@dont-email.me> <87tthrvdtg.fsf@bsb.me.uk>
<20240617181034.74fb4cca1f4a9a3ea032825e@g{oogle}mail.com>
<86r0cuk9qz.fsf@linuxsc.com>
<20240620025156.2ae9300726603b4cb3631547@gmail.moc>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Thu, 20 Jun 2024 02:34:43 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="baf3932e2944e3ee1162c1dae94de446";
logging-data="2338580"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX191Pq4KFuimfD8mNeolB8Lr"
User-Agent: Pan/0.159 (Vovchansk; 873418b; Linux-6.9.5)
Cancel-Lock: sha1:GnMV1RE2/WiQHTRo6A3zYiYkRqQ=
X-Face: \}2`P"_@pS86<'EM:'b.Ml}8IuMK"pV"?FReF$'c.S%u9<Q#U*4QO)$l81M`{Q/n
XL'`91kd%N::LG:=*\35JS0prp\VJN^<s"b#bff@fA7]5lJA.jn,x_d%Md$,{.EZ
View all headers

On Thu, 20 Jun 2024 02:51:56 +0300, Anton Shepelev <anton.txt@gmail.moc>
wrote in <20240620025156.2ae9300726603b4cb3631547@gmail.moc>:

> Cross-posting to alt.english.usage .

I've set the followup-to: same

>
> Tim Rentsch to Anton Shepelev:
>> But "one" can also be used as a first person definite pronoun
>> (referring to the speaker), which an online reference tells me is
>> chiefly British English.
>
> I had no idea it could, nor does Wikipedia. Can you share an example of
> a definite first-person `one'?

I think that would go something like:

"One wonders how..."

(Also, in some writing, "this one" can replace "I" -- this one used to do
that on Usenet, but was told it was pretentious.)

--
-v

Subject: Re: realloc() - frequency, conditions, or experiences about relocation?
From: David Brown
Newsgroups: comp.lang.c
Organization: A noiseless patient Spider
Date: Thu, 20 Jun 2024 11:22 UTC
References: 1 2 3 4 5 6 7 8 9 10 11
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: david.brown@hesbynett.no (David Brown)
Newsgroups: comp.lang.c
Subject: Re: realloc() - frequency, conditions, or experiences about
relocation?
Date: Thu, 20 Jun 2024 13:22:31 +0200
Organization: A noiseless patient Spider
Lines: 35
Message-ID: <v513dn$2i1c3$2@dont-email.me>
References: <v4ojs8$gvji$1@dont-email.me> <875xu8vsen.fsf@bsb.me.uk>
<v4ovqf$j5hq$1@dont-email.me> <87zfrjvqp6.fsf@bsb.me.uk>
<v4pb4v$lhgk$1@dont-email.me>
<20240617180249.96dfaafa89392827aa162434@g{oogle}mail.com>
<v4tuvf$1qto5$1@dont-email.me> <v4u7dm$1t2pu$1@dont-email.me>
<875xu5t066.fsf@bsb.me.uk> <v4v58t$230rh$1@dont-email.me>
<87o77wsk18.fsf@bsb.me.uk>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 20 Jun 2024 13:22:32 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="658fd1c388c737e8ccffa21e0a91fad6";
logging-data="2688387"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/Nr7sG6LeAV1JUkj1cDG6ojQmZMIkKGZw="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
Thunderbird/102.11.0
Cancel-Lock: sha1:HHh4oEy7KXMvhulUAVfhShG+I5w=
In-Reply-To: <87o77wsk18.fsf@bsb.me.uk>
Content-Language: en-GB
View all headers

On 19/06/2024 23:24, Ben Bacarisse wrote:
> David Brown <david.brown@hesbynett.no> writes:
>
>> On 19/06/2024 17:36, Ben Bacarisse wrote:
>>> Growing the buffer exponentially is simple and effective.
>>
>> Yes, that's the general way to handle buffers when you don't know what size
>> they should be.
>>
>> A better solutions for this sort of program is usually, as you say, asking
>> the OS for the file size (there is no standard library function for getting
>> the file size, but it's not hard to do for any realistic target OS). And
>> then for big files, prefer mmap to reading the file into a buffer.
>>
>> It's only really for unsized "files" such as piped input that you have no
>> way of getting the size, and then exponential growth is the way to go.
>> Personally, I'd start with a big size (perhaps 10 MB) that is bigger than
>> you are likely to need in practice, but small enough that it is negligible
>> on even vaguely modern computers. Then the realloc code is unlikely to be
>> used (but it can still be there for completeness).
>
> There are other uses that have nothing to do with files.

Of course. This comment was for the specific purposes being discussed
here. For other uses, there can be many other structures and algorithms
that fit better. Exponentially increasing the size when needed is a
good general-purpose method.

> I have a small
> dynamic array library (just a couple of function) that I use for all
> sorts of things. I can read a file or parse tokens or input a line just
> by adding characters. Because of its rather general use, I don't start
> with a large buffer (though the initial size can be set).
>

Subject: Re: Indefinite pronouns [was:Re: realloc() - frequency, conditions, or experiences about relocation?]
From: Kenny McCormack
Newsgroups: comp.lang.c, alt.english.usage
Organization: The official candy of the new Millennium
Date: Thu, 20 Jun 2024 12:10 UTC
References: 1 2 3 4
Path: eternal-september.org!news.eternal-september.org!feeder3.eternal-september.org!xmission!nnrp.xmission!.POSTED.shell.xmission.com!not-for-mail
From: gazelle@shell.xmission.com (Kenny McCormack)
Newsgroups: comp.lang.c,alt.english.usage
Subject: Re: Indefinite pronouns [was:Re: realloc() - frequency, conditions, or
experiences about relocation?]
Date: Thu, 20 Jun 2024 12:10:53 -0000 (UTC)
Organization: The official candy of the new Millennium
Message-ID: <v5168d$2fiq3$1@news.xmission.com>
References: <v4ojs8$gvji$1@dont-email.me> <20240617181034.74fb4cca1f4a9a3ea032825e@g{oogle}mail.com> <86r0cuk9qz.fsf@linuxsc.com> <20240620025156.2ae9300726603b4cb3631547@gmail.moc>
Injection-Date: Thu, 20 Jun 2024 12:10:53 -0000 (UTC)
Injection-Info: news.xmission.com; posting-host="shell.xmission.com:166.70.8.4";
logging-data="2607939"; mail-complaints-to="abuse@xmission.com"
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
Originator: gazelle@shell.xmission.com (Kenny McCormack)
View all headers

>> > I think it is a modern English idiom, which I dislike as
>> > well. StackOverflow is full of questions starting like:
>> > "How do you do this?" and "How do I do that?" They are
>> > informal ways of the more literary "How does one do
>> > this?" or "What is the way to do that?"
>>
>> I have a different take here. First the "your" of "your
>> strategy" reads as a definite pronoun, meaning it refers
>> specifically to Ben and not to some unknown other party.
>
>And I am /sure/ it is intended in the general (indefinite)
>sense, as is the `you' in Malcolm's two following sentences:

This sub-thread is certainly interesting, but it ultimately smacks of
people looking for ways to feel insulted. Victimhood complex, and all that.

But, it makes me think that the problem is the basic paradigm of newsgroup
(i.e., online forum) communication being thought of as personalized. I.e.,
as in direct person-to-person communication - as if it was being spoken in
a real room with real people (face-to-face). The fact is, it is not. It
would be better if we didn't think of it that way. Rather, it should be
thought of as communication between the speaker and an anonymous void.
I.e., I'm not talking to you - I am talking to the anonymous void.
Everybody is.

Sort of like in the (US) House of Representatives - members are not ever
supposed to be talking to each other. Rather, they are always speaking to
the void.

Like I am doing now.

This is also why it is good (And, yes, I know this goes against the CW) to
drop attributions, as I have done here. Keep it anonymous.

--

First of all, I do not appreciate your playing stupid here at all.

- Thomas 'PointedEars' Lahn -

Subject: Re: Indefinite pronouns [was: Re: <something technical>]
From: Janis Papanagnou
Newsgroups: comp.lang.c, alt.english.usage
Organization: A noiseless patient Spider
Date: Thu, 20 Jun 2024 13:04 UTC
References: 1 2 3 4 5
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: janis_papanagnou+ng@hotmail.com (Janis Papanagnou)
Newsgroups: comp.lang.c,alt.english.usage
Subject: Re: Indefinite pronouns [was: Re: <something technical>]
Date: Thu, 20 Jun 2024 15:04:00 +0200
Organization: A noiseless patient Spider
Lines: 68
Message-ID: <v519c2$2j4vg$1@dont-email.me>
References: <v4ojs8$gvji$1@dont-email.me>
<20240617181034.74fb4cca1f4a9a3ea032825e@g{oogle}mail.com>
<86r0cuk9qz.fsf@linuxsc.com>
<20240620025156.2ae9300726603b4cb3631547@gmail.moc>
<v5168d$2fiq3$1@news.xmission.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=windows-1252
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 20 Jun 2024 15:04:02 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="1a9a410acf435c06a905868c6b72f695";
logging-data="2724848"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/eZJYmrgiv5jMGj488X7tx"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
Cancel-Lock: sha1:8cRW7pJVH2GsC8+cmCCuuE0CkWI=
In-Reply-To: <v5168d$2fiq3$1@news.xmission.com>
X-Enigmail-Draft-Status: N1110
View all headers

On 20.06.2024 14:10, Kenny McCormack wrote:
>
> This sub-thread is certainly interesting, but it ultimately smacks of
> people looking for ways to feel insulted. Victimhood complex, and all that.
>
> But, it makes me think that the problem is the basic paradigm of newsgroup
> (i.e., online forum) communication being thought of as personalized. I.e.,
> as in direct person-to-person communication - as if it was being spoken in
> a real room with real people (face-to-face). The fact is, it is not. It
> would be better if we didn't think of it that way. Rather, it should be
> thought of as communication between the speaker and an anonymous void.
> I.e., I'm not talking to you - I am talking to the anonymous void.
> Everybody is.
>
> Sort of like in the (US) House of Representatives - members are not ever
> supposed to be talking to each other. Rather, they are always speaking to
> the void.
>
> Like I am doing now.
>
> This is also why it is good (And, yes, I know this goes against the CW) to
> drop attributions, as I have done here. Keep it anonymous.

Part 1

This is hard to achieve given that the technical NG infrastructure and
functions "logically" connect the articles; it's only a little burden
to identify (if not already obvious) the addressee.

I think it would be better to try to stay on the issue as opposed to
reply (as so often done) ad hominem (where arguments don't seem to
exist or don't help anymore). This is of course yet more difficult to
achieve and will in practice [also] not work in Usenet (I'm sure).

Language can be used or interpreted in personal or impersonal forms.
Some communication forms - and more so their semantical contents! -
are (beyond the "you" vs. "one" dichotomy) inherently [set up to be]
personal.

-- Anonymous
:-)

Part 2

That all said. I think it's important to know who said/posted what.
It allows to associate personal context/background information when
replying. You can also be more assured about the quality of contents
(to the good or bad) or even ignore certain posts. It saves time and
protects ones health and mental sanity.[*]

There's of course also post (or threads) that just exchange opinions,
and "we" know everyone [typically] has an opinion (and often even in
cases where they are put up against facts). Some folks are known to
post a lot, respond to every thread that appears, contributing facts
(sometimes) but also opinions (or personal offenses); this may be a
nuisance (or just ignored, unless "anonymously" posted).

So far my opinion on this non-technical meta-topic subthread.

Janis
(Darn, I disclosed my identity!)

[*] Wasn't that the inherent problem of all those "social media"
platforms? - Where anonymous posts - and some say that anonymity
does negatively contribute to the language and contents of such
disturbing posts - lead to barbarian communication conditions.
(I know that only from hearsay but it seems common perception.)

Subject: Re: realloc() - frequency, conditions, or experiences about relocation?
From: Vir Campestris
Newsgroups: comp.lang.c
Organization: A noiseless patient Spider
Date: Thu, 20 Jun 2024 20:08 UTC
References: 1 2
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: vir.campestris@invalid.invalid (Vir Campestris)
Newsgroups: comp.lang.c
Subject: Re: realloc() - frequency, conditions, or experiences about
relocation?
Date: Thu, 20 Jun 2024 21:08:00 +0100
Organization: A noiseless patient Spider
Lines: 29
Message-ID: <v52270$2nli8$1@dont-email.me>
References: <v4ojs8$gvji$1@dont-email.me>
<v4ov8h$j2q2$1@raubtier-asyl.eternal-september.org>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 20 Jun 2024 22:08:00 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="9122310e68364567a00773b3a65b23ce";
logging-data="2872904"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+PrEi4oroMgJ/VLfgx4Gd2BZs9WWjcvj4="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:KbtTignfMsWpZhaL6PE+xFScNHM=
In-Reply-To: <v4ov8h$j2q2$1@raubtier-asyl.eternal-september.org>
Content-Language: en-GB
View all headers

On 17/06/2024 10:22, Bonita Montero wrote:
>
> realloc() is just a convenience funciton. Usually the reallocation
> can't happen in-place and a second malloc() followed by a copy and
> a free() does the same.
> For large data it would be nice if the pages being deallocated later
> would be incrementally marked as discardable after copying a portion.
> This would result in only a small portion of additional physical
> memory being allocated since the newly allocated pages become asso-
> ciated with phyiscal pages when they're touched first. Windows has
> VirtualAlloc() with MEM_RESET for that, Linux has madvise() with
> MADV_DONTNEED.

"Usually can't happen in place"?

Really? It's not something I use a lot, but when it's appropriate I
will. It's got the advantage over doing this myself that for some
portion of calls all the run time library needs to do is change the size
field in the structure.

Nothing else.

No copying, and no duplicate allocations.

What proportion of calls can be managed by changing the size field alone
depends on your workload and the platform. But I doubt there are many
cases where it is 0%.

Andy

Subject: Re: Indefinite pronouns [was:Re: realloc() - frequency, conditions, or experiences about relocation?]
From: Cri-Cri
Newsgroups: comp.lang.c, alt.english.usage
Organization: Easynews - www.easynews.com
Date: Fri, 21 Jun 2024 00:55 UTC
References: 1 2 3 4 5 6 7 8 9
Path: eternal-september.org!news.eternal-september.org!feeder3.eternal-september.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer03.iad!feed-me.highwinds-media.com!peer01.ams4!peer.am4.highwinds-media.com!news.highwinds-media.com!fx05.ams4.POSTED!not-for-mail
From: cri@cri.cri.invalid (Cri-Cri)
Subject: Re: Indefinite pronouns [was:Re: realloc() - frequency, conditions,
or experiences about relocation?]
Newsgroups: comp.lang.c,alt.english.usage
References: <v4ojs8$gvji$1@dont-email.me> <875xu8vsen.fsf@bsb.me.uk>
<v4ovqf$j5hq$1@dont-email.me> <87zfrjvqp6.fsf@bsb.me.uk>
<v4pb4v$lhgk$1@dont-email.me> <87tthrvdtg.fsf@bsb.me.uk>
<20240617181034.74fb4cca1f4a9a3ea032825e@g{oogle}mail.com>
<86r0cuk9qz.fsf@linuxsc.com>
<20240620025156.2ae9300726603b4cb3631547@gmail.moc>
MIME-Version: 1.0
x-hc-9: yes
x-no-archive: yes
User-Agent: Pan/0.157 (Mariinka; 7c3c6087)
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Lines: 15
Message-ID: <Nb4dO.139759$2RJ6.5368@fx05.ams4>
X-Complaints-To: abuse@easynews.com
Organization: Easynews - www.easynews.com
X-Complaints-Info: Please be sure to forward a copy of ALL headers otherwise we will be unable to process your complaint properly.
Date: Fri, 21 Jun 2024 00:55:09 GMT
X-Received-Bytes: 1799
View all headers

On Thu, 20 Jun 2024 02:51:56 +0300, Anton Shepelev wrote:

>> But "one" can also be used as a first person definite pronoun
>> (referring to the speaker), which an online reference tells me is
>> chiefly British English.

We have the same construct in Swedish: 'en', as in "en kanske skulle kunna
ta en banan", meaning "one could perhaps have a banana." Referring to
oneself from an outside perspective, in, for instance, a situation where
there used to be several items on offer to guests, but now there are only
bananas and some dry sponge cake left. IOW, of two lesser desirable items,
one could accept a banana.

--
Cri-Cri

Subject: Re: Indefinite pronouns [was:Re: realloc() - frequency, conditions, or experiences about relocation?]
From: Tim Rentsch
Newsgroups: comp.lang.c
Organization: A noiseless patient Spider
Date: Fri, 21 Jun 2024 06:23 UTC
References: 1 2 3 4 5 6 7 8 9
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: tr.17687@z991.linuxsc.com (Tim Rentsch)
Newsgroups: comp.lang.c
Subject: Re: Indefinite pronouns [was:Re: realloc() - frequency, conditions, or experiences about relocation?]
Date: Thu, 20 Jun 2024 23:23:29 -0700
Organization: A noiseless patient Spider
Lines: 70
Message-ID: <86plsahl0e.fsf@linuxsc.com>
References: <v4ojs8$gvji$1@dont-email.me> <875xu8vsen.fsf@bsb.me.uk> <v4ovqf$j5hq$1@dont-email.me> <87zfrjvqp6.fsf@bsb.me.uk> <v4pb4v$lhgk$1@dont-email.me> <87tthrvdtg.fsf@bsb.me.uk> <20240617181034.74fb4cca1f4a9a3ea032825e@g{oogle}mail.com> <86r0cuk9qz.fsf@linuxsc.com> <20240620025156.2ae9300726603b4cb3631547@gmail.moc>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Date: Fri, 21 Jun 2024 08:23:31 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="b1207652c594f8095021b04518fba685";
logging-data="3203081"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/lm/NhwVh/id0TwY/iH5QGy92yMqrFUCY="
User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Cancel-Lock: sha1:xQnf0oEI5+2G+OQOjAhwYlq3sZ8=
sha1:FZ1cBfc62XStq9CzKad7/qP6Lko=
View all headers

Anton Shepelev <anton.txt@gmail.moc> writes:

> Cross-posting to alt.english.usage .
>
> Tim Rentsch to Anton Shepelev:
>
>>> I think it is a modern English idiom, which I dislike as
>>> well. StackOverflow is full of questions starting like:
>>> "How do you do this?" and "How do I do that?" They are
>>> informal ways of the more literary "How does one do
>>> this?" or "What is the way to do that?"
>>
>> I have a different take here. First the "your" of "your
>> strategy" reads as a definite pronoun, meaning it refers
>> specifically to Ben and not to some unknown other party.
>
> And I am /sure/ it is intended in the general (indefinite)
> sense,

I don't know why you think that. I don't know any native
English speakers who would read it as other than referring
to the person being responded to (who was Ben in this case).
Responding to Malcolm's statement, Ben said "It's odd to
call it mine", so it seems Ben also read it as a definite
pronoun, referring to himself.

As for the rest of your comments, you're reaching bad
conclusions because you're not looking in the right places.
To investigate the meaning and usage of words and phrases,
the best first place to look is always a dictionary. In
the process of writing my earlier response, I consulted
roughly half a dozen different online dictionaries, reading
definitions for 'one', 'you', 'they', 'indefinite pronoun',
'definite pronoun', and probably some other terms. I also
looked at non-dictionary sources if they looked relevant,
but my starting point was dictionaries. Oh, I also looked
up both 'idiom' and 'idiomatic' (which even though they are
related don't mean the same thing).

Incidentally, on the three pages you gave links for,
all of them had at least one example that used "you"
as an indefinite pronoun.

One point I want to clear up. A couple of times you
characterize the indefinite pronoun usage of "you"
as "modern". It is not in any sense modern. I am
a native speaker of English, speaking and reading
the language for well over 60 years. Furthermore I
was raised by a grammarian. In all of that time and
experience there was never any hint that "you" as an
indefinite pronoun was new or unusual or considered
substandard or slang or unacceptable. It is simply
standard usage, and has been for longer than my
lifetime.

>> But "one" can also be used as a first person definite
>> pronoun (referring to the speaker), which an online
>> reference tells me is chiefly British English.
>
> I had no idea it could, nor does Wikipedia. Can you share
> an example of a definite first-person `one'?

(A) Pick a good search engine (I use duckduckgo.com).
(B) Search for the two words one definition.
(C) Read the entries for every online dictionary that
is found, or at least the top five or six.

You should find a couple of examples. It was by going
through this process myself that I discovered "one"
is sometimes used as a first person definite pronoun.

Subject: Re: Indefinite pronouns
From: David Brown
Newsgroups: alt.english.usage, comp.lang.c
Organization: A noiseless patient Spider
Date: Fri, 21 Jun 2024 10:59 UTC
References: 1 2 3 4 5 6 7 8 9 10
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: david.brown@hesbynett.no (David Brown)
Newsgroups: alt.english.usage,comp.lang.c
Subject: Re: Indefinite pronouns
Date: Fri, 21 Jun 2024 12:59:43 +0200
Organization: A noiseless patient Spider
Lines: 46
Message-ID: <v53mev$34g49$2@dont-email.me>
References: <v4ojs8$gvji$1@dont-email.me> <875xu8vsen.fsf@bsb.me.uk>
<v4ovqf$j5hq$1@dont-email.me> <87zfrjvqp6.fsf@bsb.me.uk>
<v4pb4v$lhgk$1@dont-email.me> <87tthrvdtg.fsf@bsb.me.uk>
<20240617181034.74fb4cca1f4a9a3ea032825e@g{oogle}mail.com>
<86r0cuk9qz.fsf@linuxsc.com>
<20240620025156.2ae9300726603b4cb3631547@gmail.moc>
<v4vtf3$27bok$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Fri, 21 Jun 2024 12:59:43 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="017bd53d5809bfe07afbcdbc63488ddf";
logging-data="3293321"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX193YU7EsDBPcy60Fv0PdTIaW6PZDbtBTiA="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
Thunderbird/102.11.0
Cancel-Lock: sha1:OL/KXAaBCttYdbUJSaHDYQeKDcM=
In-Reply-To: <v4vtf3$27bok$1@dont-email.me>
Content-Language: en-GB
View all headers

On 20/06/2024 02:34, vallor wrote:
> On Thu, 20 Jun 2024 02:51:56 +0300, Anton Shepelev <anton.txt@gmail.moc>
> wrote in <20240620025156.2ae9300726603b4cb3631547@gmail.moc>:
>
>> Cross-posting to alt.english.usage .
>
> I've set the followup-to: same

I've put it back to comp.lang.c. It's off-topic for that group, but
that's where people were discussing it, and it seems to be of a at least
some interest to some regulars here. (I suppose maybe those regulars
are also followers of alt.english.usage.)

>
>>
>> Tim Rentsch to Anton Shepelev:
>>> But "one" can also be used as a first person definite pronoun
>>> (referring to the speaker), which an online reference tells me is
>>> chiefly British English.
>>
>> I had no idea it could, nor does Wikipedia. Can you share an example of
>> a definite first-person `one'?
>
> I think that would go something like:
>
> "One wonders how..."

It is /possible/, but archaic and very upper-class. You'd immediately
suspect the speaker is wearing a top hat.

It is much more common to say simply "I wonder how...", followed by "You
wonder how..." (with "you" being generic rather than specifically the
person listening). Such usage will be more common in some dialects than
others.

>
> (Also, in some writing, "this one" can replace "I" -- this one used to do
> that on Usenet, but was told it was pretentious.)
>

That would be even less common. The form, again archaic, would be more
usually written as "This writer used to do that..." (or "This
programmer", or however the person wanted to style himself/herself).

Subject: Re: Indefinite pronouns
From: Keith Thompson
Newsgroups: alt.english.usage, comp.lang.c
Followup: alt.english.usage
Organization: None to speak of
Date: Fri, 21 Jun 2024 17:31 UTC
References: 1 2 3 4 5 6 7 8 9 10 11
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Keith.S.Thompson+u@gmail.com (Keith Thompson)
Newsgroups: alt.english.usage,comp.lang.c
Subject: Re: Indefinite pronouns
Followup-To: alt.english.usage
Date: Fri, 21 Jun 2024 10:31:22 -0700
Organization: None to speak of
Lines: 17
Message-ID: <878qyyw6c5.fsf@nosuchdomain.example.com>
References: <v4ojs8$gvji$1@dont-email.me> <875xu8vsen.fsf@bsb.me.uk>
<v4ovqf$j5hq$1@dont-email.me> <87zfrjvqp6.fsf@bsb.me.uk>
<v4pb4v$lhgk$1@dont-email.me> <87tthrvdtg.fsf@bsb.me.uk>
<20240617181034.74fb4cca1f4a9a3ea032825e@g{oogle}mail.com>
<86r0cuk9qz.fsf@linuxsc.com>
<20240620025156.2ae9300726603b4cb3631547@gmail.moc>
<v4vtf3$27bok$1@dont-email.me> <v53mev$34g49$2@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Date: Fri, 21 Jun 2024 19:31:39 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="27ab6fe7c7a579af676e0838983f63cb";
logging-data="3440893"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18RS3iHCsOmFxqOwIFuK9RH"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Cancel-Lock: sha1:knH2TyQQrTZt8cm1hEavGNw6328=
sha1:O61QZd0Kq9Ev88UsYeSCTvfPXO4=
View all headers

David Brown <david.brown@hesbynett.no> writes:
> On 20/06/2024 02:34, vallor wrote:
>> On Thu, 20 Jun 2024 02:51:56 +0300, Anton Shepelev <anton.txt@gmail.moc>
>> wrote in <20240620025156.2ae9300726603b4cb3631547@gmail.moc>:
>>
>>> Cross-posting to alt.english.usage .
>> I've set the followup-to: same
>
> I've put it back to comp.lang.c. It's off-topic for that group,

Please don't do that.

[...]

--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
void Void(void) { Void(); } /* The recursive call of the void */

Subject: Re: realloc() - frequency, conditions, or experiences about relocation?
From: Bonita Montero
Newsgroups: comp.lang.c
Organization: A noiseless patient Spider
Date: Fri, 21 Jun 2024 19:12 UTC
References: 1 2 3
Path: eternal-september.org!news.eternal-september.org!raubtier-asyl.eternal-september.org!.POSTED!not-for-mail
From: Bonita.Montero@gmail.com (Bonita Montero)
Newsgroups: comp.lang.c
Subject: Re: realloc() - frequency, conditions, or experiences about
relocation?
Date: Fri, 21 Jun 2024 21:12:12 +0200
Organization: A noiseless patient Spider
Lines: 26
Message-ID: <v54jac$3a4p2$1@raubtier-asyl.eternal-september.org>
References: <v4ojs8$gvji$1@dont-email.me>
<v4ov8h$j2q2$1@raubtier-asyl.eternal-september.org>
<v52270$2nli8$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Fri, 21 Jun 2024 21:12:12 +0200 (CEST)
Injection-Info: raubtier-asyl.eternal-september.org; posting-host="cc301cc675ded9210432743989896874";
logging-data="3478306"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19D+HENybx+FHKjDVNW7ySBRafMVHmFtdA="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:rI1CbtzoyeaUZZNlvnBL9yf1XZc=
Content-Language: de-DE
In-Reply-To: <v52270$2nli8$1@dont-email.me>
View all headers

Am 20.06.2024 um 22:08 schrieb Vir Campestris:
> On 17/06/2024 10:22, Bonita Montero wrote:
>>
>> realloc() is just a convenience funciton. Usually the reallocation
>> can't happen in-place and a second malloc() followed by a copy and
>> a free() does the same.
>> For large data it would be nice if the pages being deallocated later
>> would be incrementally marked as discardable after copying a portion.
>> This would result in only a small portion of additional physical
>> memory being allocated since the newly allocated pages become asso-
>> ciated with phyiscal pages when they're touched first. Windows has
>> VirtualAlloc() with MEM_RESET for that, Linux has madvise() with
>> MADV_DONTNEED.
>
> "Usually can't happen in place"?

Usually you don't resize the block with a few bytes and if you have
a large memory area it's unlikely that you can allocate a few additional
pages in-place.
C++23 has a nice function with the allocator interface called allocate
_at_least. It returns the pointer to the allocated memory with the size
actually allocated. This fits with modern allocators like mimalloc, je-
malloc or tcmalloc, which round up the allocation to the next 2 ^ N
boundary up to 8kB. So a vector's capacity directly includes the blend.

Subject: Re: realloc() - frequency, conditions, or experiences about relocation?
From: Lawrence D'Oliv
Newsgroups: comp.lang.c
Organization: A noiseless patient Spider
Date: Mon, 24 Jun 2024 08:40 UTC
References: 1 2 3 4
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: ldo@nz.invalid (Lawrence D'Oliveiro)
Newsgroups: comp.lang.c
Subject: Re: realloc() - frequency, conditions, or experiences about
relocation?
Date: Mon, 24 Jun 2024 08:40:03 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 14
Message-ID: <v5bbd3$rhao$2@dont-email.me>
References: <v4ojs8$gvji$1@dont-email.me>
<v4ov8h$j2q2$1@raubtier-asyl.eternal-september.org>
<v52270$2nli8$1@dont-email.me>
<v54jac$3a4p2$1@raubtier-asyl.eternal-september.org>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Mon, 24 Jun 2024 10:40:05 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="3048fea01d51f9337586ac8e02824e6c";
logging-data="902488"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18+em28bzjCK4Sv7usPscyL"
User-Agent: Pan/0.158 (Avdiivka; )
Cancel-Lock: sha1:MQTEmnDn1hgbSZ9BNO+Fi9zKdls=
View all headers

On Fri, 21 Jun 2024 21:12:12 +0200, Bonita Montero wrote:

> Usually you don't resize the block with a few bytes ...

The usual way I use realloc is to maintain separate counts of the number
of array elements I have allocated, and the number I am actually using. A
realloc call is only needed when the latter hits the former. Every time I
call realloc, I will extend by some minimum number of array elements (e.g.
128), roughly comparable to the sort of array size I typically end up
with.

And then when the structure is complete, I do a final realloc call to
shrink it down so the size is actually that used. Is it safe to assume
such a call will never fail? Hmm ...

Subject: Re: realloc() - frequency, conditions, or experiences about relocation?
From: Keith Thompson
Newsgroups: comp.lang.c
Organization: None to speak of
Date: Mon, 24 Jun 2024 09:55 UTC
References: 1 2 3 4 5
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Keith.S.Thompson+u@gmail.com (Keith Thompson)
Newsgroups: comp.lang.c
Subject: Re: realloc() - frequency, conditions, or experiences about relocation?
Date: Mon, 24 Jun 2024 02:55:39 -0700
Organization: None to speak of
Lines: 41
Message-ID: <875xtyu0kk.fsf@nosuchdomain.example.com>
References: <v4ojs8$gvji$1@dont-email.me>
<v4ov8h$j2q2$1@raubtier-asyl.eternal-september.org>
<v52270$2nli8$1@dont-email.me>
<v54jac$3a4p2$1@raubtier-asyl.eternal-september.org>
<v5bbd3$rhao$2@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Date: Mon, 24 Jun 2024 11:55:40 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="0a690d6294358a2c4bce5879f14e083a";
logging-data="921546"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/jIJt8cubpkcQgjAPAGOsS"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Cancel-Lock: sha1:xwGQX65ed2O+vwImQ/DajeUTBhk=
sha1:6GxzpYfw4wQ+bbtMZavOdo1a3u8=
View all headers

Lawrence D'Oliveiro <ldo@nz.invalid> writes:
> On Fri, 21 Jun 2024 21:12:12 +0200, Bonita Montero wrote:
>> Usually you don't resize the block with a few bytes ...
>
> The usual way I use realloc is to maintain separate counts of the number
> of array elements I have allocated, and the number I am actually using. A
> realloc call is only needed when the latter hits the former. Every time I
> call realloc, I will extend by some minimum number of array elements (e.g.
> 128), roughly comparable to the sort of array size I typically end up
> with.
>
> And then when the structure is complete, I do a final realloc call to
> shrink it down so the size is actually that used. Is it safe to assume
> such a call will never fail? Hmm ...

It's not safe to assume that a shrinking realloc call will never fail.
It's possible that it will never fail in any existing implementation,
but the standard makes no such guarantee.

A (perhaps) plausible way it can fail is if allocations of different
sizes are allocated from different pools. Trying to shrink a 1000-byte
object to 100 bytes might fail if the 100-byte pool has been exhausted.
On the other hand, realloc() could just return its argument in such a
case and continue treating the object as a 1000-byte allocation.
(The allocation functions don't have to keep track of how much memory
you asked for, only how much they actually allocated, which is >= what
you asked for.)

Arguably only a poor implementation would fail on a shrinking realloc(),
but the standard permits poor implementations.

Having said all that, if realloc fails (indicated by returning a null
pointer), you still have the original pointer to the object.

Something else that occurs to me: If a shrinking realloc() never fails
in practice, then any code you write to handle a failure won't be
tested.

--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
void Void(void) { Void(); } /* The recursive call of the void */

Pages:1234

rocksolid light 0.9.8
clearnet tor