Re: realloc() - frequency, conditions, or experiences about relocation?

Liste des GroupesRevenir à ss math 
Sujet : Re: realloc() - frequency, conditions, or experiences about relocation?
De : anton.txt (at) *nospam* g{oogle}mail.com (Anton Shepelev)
Groupes : comp.lang.c sci.stat.math
Date : 08. Jul 2024, 19:01:21
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <20240708200121.ec07d0338a336b56cc7387a1@g{oogle}mail.com>
References : 1 2 3 4 5 6 7 8 9
User-Agent : Sylpheed 3.7.0 (GTK+ 2.24.30; i686-pc-mingw32)
Rich Ulrich:

Thanks, so it looks like a failure by GigaNews to retrieve
the recent posts.
>
I did see a bunch of cross-posted followups. I don't know
C, and I thought there could be more context.

Characters are being read in (say, from a file) sequentially
and stored in computer memory (RAM) in an "array" -- a
linear data structure storing elements (our characters) in a
sequential order, one ofter the other at addresses with
increasing indexes -- somewhat like a mathematical vector.

In order to store a character in an array, sufficient memory
has to be "allocated" for it, but while reading we do not
know beforehand the size of the file (or the total length of
the sequence), and therefore increase the allocated aray
size prospectively once the previous allocation is filled.
This operaion is called `realloc' and frequently involves
the tedious copying of the entire array onto a new location
in memory, taking a time in proportion to the number
elemennts so far allocated.

The question is to develop an optimal allcation strategy for
a given distribution of file sizes.  The fasted solution is
to allocate a gigantic array beforehand, but it is a
terrible waste of memory.  The slowet solution is to
reallcoate for each single character read it, but is a
terrible waste of CPU time.  As I understand the problem, a
strategy is needed that manifests some compromise between
the extremes.

Looking at original, absent posts is something I've done
dozens of times over the years.  Never a problem, except
fora time or two with posts from the 1990s.  I've used
GigaNews since my regular ISP stopped providing Usenet
access, maybe 15 years ago.

Just in case, there are many totally free Usenet servers,
e.g.:
             http://www.eternal-september.org/
             https://www.i2pn2.org/

and even a web interface:

             https://www.novabbs.com

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

Date Sujet#  Auteur
17 Jun 24 * Re: realloc() - frequency, conditions, or experiences about relocation?22Anton Shepelev
18 Jun 24 +- Re: realloc() - frequency, conditions, or experiences about relocation?1David Jones
19 Jun 24 +* Re: realloc() - frequency, conditions, or experiences about relocation?8David Duffy
19 Jun 24 i+* Re: realloc() - frequency, conditions, or experiences about relocation?6Malcolm McLean
19 Jun 24 ii+* Re: realloc() - frequency, conditions, or experiences about relocation?3Ben Bacarisse
19 Jun 24 iii`* Re: realloc() - frequency, conditions, or experiences about relocation?2David Brown
19 Jun 24 iii `- Re: realloc() - frequency, conditions, or experiences about relocation?1Ben Bacarisse
20 Jun 24 ii`* Re: realloc() - frequency, conditions, or experiences about relocation?2Anton Shepelev
8 Jul 24 ii `- Re: realloc() - frequency, conditions, or experiences about relocation?1Anton Shepelev
19 Jun 24 i`- Re: realloc() - frequency, conditions, or experiences about relocation?1Anton Shepelev
2 Jul 24 `* Re: realloc() - frequency, conditions, or experiences about relocation?12Rich Ulrich
2 Jul 24  +* Re: realloc() - frequency, conditions, or experiences about relocation?5Keith Thompson
2 Jul 24  i`* Re: realloc() - frequency, conditions, or experiences about relocation?4Rich Ulrich
8 Jul 24  i `* Re: realloc() - frequency, conditions, or experiences about relocation?3Anton Shepelev
22 Jul 24  i  `* Re: realloc() - frequency, conditions, or experiences about relocation?2Rich Ulrich
23 Jul 24  i   `- Re: realloc() - frequency, conditions, or experiences about relocation?1Anton Shepelev
2 Jul 24  `* Re: realloc() - frequency, conditions, or experiences about relocation?6Paul
2 Jul 24   `* Re: realloc() - frequency, conditions, or experiences about relocation?5Rich Ulrich
2 Jul 24    `* Re: realloc() - frequency, conditions, or experiences about relocation?4Rich Ulrich
2 Jul 24     `* Re: realloc() - frequency, conditions, or experiences about relocation?3Paul
2 Jul 24      +- Re: realloc() - frequency, conditions, or experiences about relocation?1James Kuyper
2 Jul 24      `- Re: realloc() - frequency, conditions, or experiences about relocation?1James Kuyper

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal