Re: Joy of this, Joy of that

Liste des GroupesRevenir à col misc 
Sujet : Re: Joy of this, Joy of that
De : tnp (at) *nospam* invalid.invalid (The Natural Philosopher)
Groupes : comp.os.linux.misc
Date : 28. Nov 2024, 10:16:51
Autres entêtes
Organisation : A little, after lunch
Message-ID : <vi9ce3$fjo6$7@dont-email.me>
References : 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
User-Agent : Mozilla Thunderbird
On 27/11/2024 18:58, Rich wrote:
The Natural Philosopher <tnp@invalid.invalid> wrote:
On 27/11/2024 16:33, Rich wrote:
The Natural Philosopher <tnp@invalid.invalid> wrote:
On 27/11/2024 01:48, Rich wrote:
The only two guarantees given in that paragraph are:
>
1) if ptr was returned by one of the malloc's, the space referenced by
      ptr is deallocated (albeit only for the first call of free(ptr), per
      the second sentence);
and
2) if ptr is NULL, nothing occurs.
>
Exactly.  The result of anything else is implementation dependent on the
library.
>
One might write a free that says 'look at our list of allocated blocks,
compare with the pointer and if no match do nothing'
>
Or one that says  'look at our list of allocated block compare with the
pointer and if no match, segfault'
>
I am not au fait with the internal of 'free()' so I cannot comment as to
why the first is not always the case.
>
I can hazzard a guess.  The time taken to perform the search, or the
effort needed to maintain an "index structure" to perform an optimized
search, plus the time for the optimized search, was felt to be
excessive and wasteful when the "spec" says "don't ever do this".
>
>
Look I don't know how memory allocation and de allocation is done
but my instinct would be to hold a long list of pointers to allocated
blocks.  Possibly in order of the allocated addresses, which would make
allocating a new block a case of finding the first gap in the list that
is [required blocksize] and inserting a new list element, and de
allocation a question of searching the list for a matching allocation,
and deleting it from the list.
>
It would be trivial to get to the end of the list and discover that that
was the end, and, with no match found simply ignore the free call
 Yes, but now you burden /every/ free(ptr) call with an O(N) linear
search of all allocated blocks to determine if "ptr" has been
previously freed.  With today's CPU's one could be excused in thinking
"not such a big deal".  In the days of a PDP-11 or VAX-11/780 CPU
performance levels, doing an O(N) linear search, on every call to free,
to catch something the programmer was never supposed to do in the first
place, was likely viewed as too much overhead.
 
How else would you do it?
--
For every complex problem there is an answer that is clear, simple, and wrong.
H.L.Mencken

Date Sujet#  Auteur
19 Nov 24 * Joy of this, Joy of that806root
20 Nov 24 +* Re: Joy of this, Joy of that4Lawrence D'Oliveiro
20 Nov 24 i`* Re: Joy of this, Joy of that3root
20 Nov 24 i +- Re: Joy of this, Joy of that1Lawrence D'Oliveiro
20 Nov 24 i `- Re: Joy of this, Joy of that1rbowman
20 Nov 24 `* Re: Joy of this, Joy of that801186282@ud0s4.net
20 Nov 24  +* Re: Joy of this, Joy of that193Rich
20 Nov 24  i+- Re: Joy of this, Joy of that1The Natural Philosopher
21 Nov 24  i`* Re: Joy of this, Joy of that191186282@ud0s4.net
21 Nov 24  i +* Re: Joy of this, Joy of that2Lawrence D'Oliveiro
14 Jan 25  i i`- Re: Joy of this, Joy of that1Bozo User
21 Nov 24  i +* Re: Joy of this, Joy of that187The Natural Philosopher
22 Nov 24  i i`* Re: Joy of this, Joy of that186Don_from_AZ
22 Nov 24  i i `* Re: Joy of this, Joy of that185Lawrence D'Oliveiro
23 Nov 24  i i  `* Re: Joy of this, Joy of that184186282@ud0s4.net
23 Nov 24  i i   +* Re: Joy of this, Joy of that5Lawrence D'Oliveiro
24 Nov 24  i i   i`* Re: Joy of this, Joy of that4186282@ud0s4.net
24 Nov 24  i i   i +* Re: Joy of this, Joy of that2Lawrence D'Oliveiro
24 Nov 24  i i   i i`- Re: Joy of this, Joy of that1186282@ud0s4.net
24 Nov 24  i i   i `- Re: Joy of this, Joy of that1rbowman
23 Nov 24  i i   `* Re: Joy of this, Joy of that178The Natural Philosopher
23 Nov 24  i i    +- Re: Joy of this, Joy of that1rbowman
23 Nov 24  i i    +- Re: Joy of this, Joy of that1Lawrence D'Oliveiro
24 Nov 24  i i    +* Re: Joy of this, Joy of that174186282@ud0s4.net
24 Nov 24  i i    i+- Re: Joy of this, Joy of that1rbowman
24 Nov 24  i i    i`* Re: Joy of this, Joy of that172Rich
24 Nov 24  i i    i +* Re: Joy of this, Joy of that168The Natural Philosopher
24 Nov 24  i i    i i+* Re: Joy of this, Joy of that159Rich
24 Nov 24  i i    i ii`* Re: Joy of this, Joy of that158D
25 Nov 24  i i    i ii `* Re: Joy of this, Joy of that157rbowman
25 Nov 24  i i    i ii  `* Re: Joy of this, Joy of that156D
25 Nov 24  i i    i ii   `* Re: Joy of this, Joy of that155The Natural Philosopher
25 Nov 24  i i    i ii    +* Re: Joy of this, Joy of that15D
26 Nov 24  i i    i ii    i`* Re: Joy of this, Joy of that14rbowman
26 Nov 24  i i    i ii    i +- Re: Joy of this, Joy of that1D
26 Nov 24  i i    i ii    i `* Re: Joy of this, Joy of that12Pancho
26 Nov 24  i i    i ii    i  `* Re: Joy of this, Joy of that11Rich
26 Nov 24  i i    i ii    i   +* Re: Joy of this, Joy of that2Chris Ahlstrom
27 Nov 24  i i    i ii    i   i`- Re: Joy of this, Joy of that1Pancho
26 Nov 24  i i    i ii    i   `* Re: Joy of this, Joy of that8rbowman
26 Nov 24  i i    i ii    i    +* Re: Joy of this, Joy of that4D
27 Nov 24  i i    i ii    i    i+- Re: Joy of this, Joy of that1Rich
27 Nov 24  i i    i ii    i    i`* Re: Joy of this, Joy of that2rbowman
27 Nov 24  i i    i ii    i    i `- Re: Joy of this, Joy of that1D
27 Nov 24  i i    i ii    i    `* Re: Joy of this, Joy of that3The Natural Philosopher
27 Nov 24  i i    i ii    i     `* Re: Joy of this, Joy of that2rbowman
28 Nov 24  i i    i ii    i      `- Re: Joy of this, Joy of that1The Natural Philosopher
25 Nov 24  i i    i ii    `* Re: Joy of this, Joy of that139Lawrence D'Oliveiro
27 Nov 24  i i    i ii     `* Re: Joy of this, Joy of that138186282@ud0s4.net
27 Nov 24  i i    i ii      `* Re: Joy of this, Joy of that137Lawrence D'Oliveiro
28 Nov 24  i i    i ii       `* Re: Joy of this, Joy of that136186282@ud0s4.net
28 Nov 24  i i    i ii        +* Re: Joy of this, Joy of that133rbowman
28 Nov 24  i i    i ii        i`* Re: Joy of this, Joy of that132186282@ud0s4.net
28 Nov 24  i i    i ii        i +* Re: Joy of this, Joy of that3rbowman
29 Nov 24  i i    i ii        i i`* Re: Joy of this, Joy of that2186282@ud0s4.net
29 Nov 24  i i    i ii        i i `- Re: Joy of this, Joy of that1rbowman
28 Nov 24  i i    i ii        i `* Re: Joy of this, Joy of that128Lawrence D'Oliveiro
29 Nov 24  i i    i ii        i  `* Re: Joy of this, Joy of that127186282@ud0s4.net
29 Nov 24  i i    i ii        i   +* Re: Joy of this, Joy of that116rbowman
30 Nov 24  i i    i ii        i   i`* Re: Joy of this, Joy of that115186282@ud0s4.net
30 Nov 24  i i    i ii        i   i +- Re: Joy of this, Joy of that1Lawrence D'Oliveiro
30 Nov 24  i i    i ii        i   i `* Re: Joy of this, Joy of that113rbowman
30 Nov 24  i i    i ii        i   i  +* Re: Joy of this, Joy of that2The Natural Philosopher
1 Dec 24  i i    i ii        i   i  i`- Re: Joy of this, Joy of that1Lawrence D'Oliveiro
1 Dec 24  i i    i ii        i   i  `* Re: Joy of this, Joy of that110186282@ud0s4.net
1 Dec 24  i i    i ii        i   i   +* Re: Joy of this, Joy of that5The Natural Philosopher
1 Dec 24  i i    i ii        i   i   i+* Re: Joy of this, Joy of that2Rich
3 Dec 24  i i    i ii        i   i   ii`- Re: Joy of this, Joy of that1186282@ud0s4.net
1 Dec 24  i i    i ii        i   i   i+- Re: Joy of this, Joy of that1D
2 Dec 24  i i    i ii        i   i   i`- Re: Joy of this, Joy of that1186282@ud0s4.net
1 Dec 24  i i    i ii        i   i   +* Re: Joy of this, Joy of that2Lawrence D'Oliveiro
3 Dec 24  i i    i ii        i   i   i`- Re: Joy of this, Joy of that1186282@ud0s4.net
1 Dec 24  i i    i ii        i   i   `* Re: Joy of this, Joy of that102rbowman
3 Dec 24  i i    i ii        i   i    `* Re: Joy of this, Joy of that101186282@ud0s4.net
3 Dec 24  i i    i ii        i   i     +* Re: Joy of this, Joy of that2The Natural Philosopher
3 Dec 24  i i    i ii        i   i     i`- Re: Joy of this, Joy of that1rbowman
3 Dec 24  i i    i ii        i   i     `* Re: Joy of this, Joy of that98rbowman
5 Dec 24  i i    i ii        i   i      `* Re: Joy of this, Joy of that97186282@ud0s4.net
5 Dec 24  i i    i ii        i   i       +* Re: Joy of this, Joy of that92D
6 Dec 24  i i    i ii        i   i       i`* Re: Joy of this, Joy of that91186282@ud0s4.net
6 Dec 24  i i    i ii        i   i       i +* Re: Joy of this, Joy of that37rbowman
6 Dec 24  i i    i ii        i   i       i i+* Re: Joy of this, Joy of that34D
7 Dec 24  i i    i ii        i   i       i ii+* Re: Joy of this, Joy of that2186282@ud0s4.net
7 Dec 24  i i    i ii        i   i       i iii`- Re: Joy of this, Joy of that1D
7 Dec 24  i i    i ii        i   i       i ii+* Re: Joy of this, Joy of that17186282@ud0s4.net
7 Dec 24  i i    i ii        i   i       i iii`* Re: Joy of this, Joy of that16D
7 Dec 24  i i    i ii        i   i       i iii +* Re: Joy of this, Joy of that14Rich
7 Dec 24  i i    i ii        i   i       i iii i`* Re: Joy of this, Joy of that13D
7 Dec 24  i i    i ii        i   i       i iii i `* Re: Joy of this, Joy of that12Rich
7 Dec 24  i i    i ii        i   i       i iii i  +* Re: Joy of this, Joy of that10D
8 Dec 24  i i    i ii        i   i       i iii i  i+* Re: Joy of this, Joy of that7Rich
8 Dec 24  i i    i ii        i   i       i iii i  ii+* Re: Joy of this, Joy of that5rbowman
8 Dec 24  i i    i ii        i   i       i iii i  iii`* Re: Joy of this, Joy of that4Rich
8 Dec 24  i i    i ii        i   i       i iii i  iii +* Re: Joy of this, Joy of that2The Natural Philosopher
9 Dec 24  i i    i ii        i   i       i iii i  iii i`- Re: Joy of this, Joy of that1The Natural Philosopher
8 Dec 24  i i    i ii        i   i       i iii i  iii `- Re: Joy of this, Joy of that1rbowman
8 Dec 24  i i    i ii        i   i       i iii i  ii`- Re: Joy of this, Joy of that1D
8 Dec 24  i i    i ii        i   i       i iii i  i`* Re: Joy of this, Joy of that2Robert Riches
8 Dec 24  i i    i ii        i   i       i iii i  i `- Re: Joy of this, Joy of that1D
7 Dec 24  i i    i ii        i   i       i iii i  `- Re: Joy of this, Joy of that1D
8 Dec 24  i i    i ii        i   i       i iii `- Re: Joy of this, Joy of that1186282@ud0s4.net
7 Dec 24  i i    i ii        i   i       i ii`* Re: Joy of this, Joy of that14D
7 Dec 24  i i    i ii        i   i       i i`* Re: Joy of this, Joy of that2186282@ud0s4.net
6 Dec 24  i i    i ii        i   i       i `* Re: Joy of this, Joy of that53D
5 Dec 24  i i    i ii        i   i       `* Re: Joy of this, Joy of that4Lawrence D'Oliveiro
29 Nov 24  i i    i ii        i   `* Re: Joy of this, Joy of that10Lawrence D'Oliveiro
28 Nov 24  i i    i ii        `* Re: Joy of this, Joy of that2Lawrence D'Oliveiro
25 Nov 24  i i    i i`* Re: Joy of this, Joy of that8vallor
24 Nov 24  i i    i `* Re: Joy of this, Joy of that3D
24 Nov 24  i i    `- Re: Joy of this, Joy of that1Rich
21 Nov 24  i `- Re: Joy of this, Joy of that1Rich
20 Nov 24  +* Re: Joy of this, Joy of that606John Ames
20 Nov 24  `- Re: Joy of this, Joy of that1rbowman

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal