Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

1 + 1 = 3, for large values of 1.


devel / comp.lang.c / Re: pointers are evil (mostly)

SubjectAuthor
* pointers are evil (mostly)fir
+- Re: pointers are evil (mostly)fir
+* Re: pointers are evil (mostly)Ed Prochak
|+* Re: pointers are evil (mostly)fir
||`* Re: pointers are evil (mostly)Ed Prochak
|| +* Re: pointers are evil (mostly)James Kuyper
|| |+* Re: pointers are evil (mostly)fir
|| ||`* Re: pointers are evil (mostly)Ed Prochak
|| || `* Re: pointers are evil (mostly)fir
|| ||  `* Re: pointers are evil (mostly)fir
|| ||   +* Re: pointers are evil (mostly)fir
|| ||   |`* Re: pointers are evil (mostly)Ed Prochak
|| ||   | `* Re: pointers are evil (mostly)Anton Shepelev
|| ||   |  `* Re: pointers are evil (mostly)olcott
|| ||   |   +* Re: pointers are evil (mostly)Vir Campestris
|| ||   |   |`- Re: pointers are evil (mostly)olcott
|| ||   |   `* Re: pointers are evil (mostly)Ed Prochak
|| ||   |    `* Re: pointers are evil (mostly)olcott
|| ||   |     +* Re: pointers are evil (mostly)jak.
|| ||   |     |`- Re: pointers are evil (mostly)Ed Prochak
|| ||   |     `* Re: pointers are evil (mostly)Ed Prochak
|| ||   |      +- Re: pointers are evil (mostly)olcott
|| ||   |      +* Re: pointers are evil (mostly)jak.
|| ||   |      |`* Re: pointers are evil (mostly)olcott
|| ||   |      | +- Re: pointers are evil (mostly)jak
|| ||   |      | `- Re: pointers are evil (mostly)jak
|| ||   |      `- Re: pointers are evil (mostly)Vir Campestris
|| ||   `- Re: pointers are evil (mostly)Ed Prochak
|| |`- Re: pointers are evil (mostly)Ed Prochak
|| `* Re: pointers are evil (mostly)Scott Lurndal
||  `- Re: pointers are evil (mostly)Ed Prochak
|`* Re: pointers are evil (mostly)James Kuyper
| +- Re: pointers are evil (mostly)Kaz Kylheku
| +* Re: pointers are evil (mostly)David Brown
| |+- Re: pointers are evil (mostly)James Kuyper
| |`- Re: pointers are evil (mostly)James Kuyper
| `- Re: pointers are evil (mostly)Ed Prochak
`- Re: pointers are evil (mostly)Bonita Montero

Pages:12
Re: pointers are evil (mostly)

<tv26au$21ren$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=25081&group=comp.lang.c#25081

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!rocksolid2!news.neodome.net!weretis.net!feeder8.news.weretis.net!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: vir.camp...@invalid.invalid (Vir Campestris)
Newsgroups: comp.lang.c
Subject: Re: pointers are evil (mostly)
Date: Fri, 17 Mar 2023 17:00:14 +0000
Organization: A noiseless patient Spider
Lines: 21
Message-ID: <tv26au$21ren$1@dont-email.me>
References: <41bb299a-3bf2-4064-9f54-75bcc81fb12en@googlegroups.com>
<0f13b041-8675-4ce5-aa98-f9604b87f7d3n@googlegroups.com>
<a3e126a4-d38d-4071-ade5-752b20aacbe6n@googlegroups.com>
<93bdd10d-d175-4186-85d7-9c06235ea5c5n@googlegroups.com>
<tt6rbr$1pkqc$1@dont-email.me>
<410fa1b3-de17-49a6-9ab4-740fc7546a38n@googlegroups.com>
<a6334787-03bd-43cb-a600-a935831efc72n@googlegroups.com>
<fb841003-5837-4094-b5cb-e826b9156c4an@googlegroups.com>
<622f4169-0b86-4ef9-96cd-a2ede98a5b53n@googlegroups.com>
<e53b8493-b668-45e9-a13f-9cd7622d5e54n@googlegroups.com>
<f89b7f3e-46fd-4ed9-a091-2a7cbd8569adn@googlegroups.com>
<20230309120746.4e35005129f964b86a4de87f@g{oogle}mail.com>
<tuvu72$1iiar$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Fri, 17 Mar 2023 17:00:15 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="fba00a29a8b8e604f5ea1d99d764a4cc";
logging-data="2158039"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/9U8tHdU5md1le4ZDhChNoCq8PztXUuvE="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
Thunderbird/102.8.0
Cancel-Lock: sha1:eNT1Dp4CjAwlazUqBbKca6iHWRY=
Content-Language: en-GB
In-Reply-To: <tuvu72$1iiar$1@dont-email.me>
 by: Vir Campestris - Fri, 17 Mar 2023 17:00 UTC

On 16/03/2023 20:29, olcott wrote:
> The memory leak errors made possible by pointers can be easily
> eliminated by compiling the code as C++ and using the standard template
> library for all memory allocation.

The first major change I made in my last job was exactly that - there
was code that stored raw pointers all over the place, and we were
getting crashes when something accessed an object that had been deleted.
Well, sometimes crashes... UB anyway.

But easy? It took me several weeks to go through and work out which
places needed shared_ptr, and which needed weak_ptr. Some bits of code
didn't own the objects, but needed to look through them all. And our
code base was _already_ C++.

I got one wrong. We ended up with a memory leak because one of the pools
was keeping dead objects allocated. Not a leak in the classical sense -
a block of memory where nobody knows where it is - but still memory
being used up over time until we ran out.

Andy

Re: pointers are evil (mostly)

<tv2787$229s1$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=25082&group=comp.lang.c#25082

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: polco...@gmail.com (olcott)
Newsgroups: comp.lang.c
Subject: Re: pointers are evil (mostly)
Date: Fri, 17 Mar 2023 12:15:50 -0500
Organization: A noiseless patient Spider
Lines: 43
Message-ID: <tv2787$229s1$1@dont-email.me>
References: <41bb299a-3bf2-4064-9f54-75bcc81fb12en@googlegroups.com>
<0f13b041-8675-4ce5-aa98-f9604b87f7d3n@googlegroups.com>
<a3e126a4-d38d-4071-ade5-752b20aacbe6n@googlegroups.com>
<93bdd10d-d175-4186-85d7-9c06235ea5c5n@googlegroups.com>
<tt6rbr$1pkqc$1@dont-email.me>
<410fa1b3-de17-49a6-9ab4-740fc7546a38n@googlegroups.com>
<a6334787-03bd-43cb-a600-a935831efc72n@googlegroups.com>
<fb841003-5837-4094-b5cb-e826b9156c4an@googlegroups.com>
<622f4169-0b86-4ef9-96cd-a2ede98a5b53n@googlegroups.com>
<e53b8493-b668-45e9-a13f-9cd7622d5e54n@googlegroups.com>
<f89b7f3e-46fd-4ed9-a091-2a7cbd8569adn@googlegroups.com>
<20230309120746.4e35005129f964b86a4de87f@g{oogle}mail.com>
<tuvu72$1iiar$1@dont-email.me> <tv26au$21ren$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Fri, 17 Mar 2023 17:15:51 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="e0e44e1988a319520dd6c94ccc6b513a";
logging-data="2172801"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+DzPRNsmgASpam56lJqa9j"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.8.0
Cancel-Lock: sha1:/WDl/cQpy5WuYCjnwePu8qS097I=
In-Reply-To: <tv26au$21ren$1@dont-email.me>
Content-Language: en-US
 by: olcott - Fri, 17 Mar 2023 17:15 UTC

On 3/17/2023 12:00 PM, Vir Campestris wrote:
> On 16/03/2023 20:29, olcott wrote:
>> The memory leak errors made possible by pointers can be easily
>> eliminated by compiling the code as C++ and using the standard template
>> library for all memory allocation.
>
> The first major change I made in my last job was exactly that - there
> was code that stored raw pointers all over the place, and we were
> getting crashes when something accessed an object that had been deleted.
> Well, sometimes crashes... UB anyway.
>
> But easy? It took me several weeks to go through and work out which
> places needed shared_ptr, and which needed weak_ptr. Some bits of code
> didn't own the objects, but needed to look through them all. And our
> code base was _already_ C++.
>
> I got one wrong. We ended up with a memory leak because one of the pools
> was keeping dead objects allocated. Not a leak in the classical sense -
> a block of memory where nobody knows where it is - but still memory
> being used up over time until we ran out.
>
> Andy

When I converted from C programming to C++ programming all new systems
only used the standard template library for all dynamic memory
allocation. I have always hated the tediousness of pointers so much that
I never did any dynamic memory allocation until after I switched to C++.

With std::vector a huge array of very large objects can be stored in a
local variable that has its memory correctly automatically deallocated
as soon as the function returns. Memory is also automatically allocated
as needed with push_back().

The only other thing that I use from C++ is classes/objects. The key
benefit of OOP is utterly eliminating the possibility of global side-
effects. When functionality and data are totally contained within the
same object then the extraneous complexity of global side-effects is
abolished.

--
Copyright 2023 Olcott "Talent hits a target no one else can hit; Genius
hits a target no one else can see." Arthur Schopenhauer

Re: pointers are evil (mostly)

<a8712cee-21f9-4910-9566-f87f1a70d774n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=25086&group=comp.lang.c#25086

  copy link   Newsgroups: comp.lang.c
X-Received: by 2002:a05:620a:1307:b0:745:f645:a4ab with SMTP id o7-20020a05620a130700b00745f645a4abmr2412250qkj.2.1679087922190;
Fri, 17 Mar 2023 14:18:42 -0700 (PDT)
X-Received: by 2002:a81:ad5a:0:b0:544:4008:baa1 with SMTP id
l26-20020a81ad5a000000b005444008baa1mr5694764ywk.4.1679087921927; Fri, 17 Mar
2023 14:18:41 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.c
Date: Fri, 17 Mar 2023 14:18:41 -0700 (PDT)
In-Reply-To: <tuvu72$1iiar$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=2600:1700:5f82:5000:55c4:a402:84ca:9ec0;
posting-account=3ty6FAkAAACYEfch20jQ1ZACFatw-Vdx
NNTP-Posting-Host: 2600:1700:5f82:5000:55c4:a402:84ca:9ec0
References: <41bb299a-3bf2-4064-9f54-75bcc81fb12en@googlegroups.com>
<0f13b041-8675-4ce5-aa98-f9604b87f7d3n@googlegroups.com> <a3e126a4-d38d-4071-ade5-752b20aacbe6n@googlegroups.com>
<93bdd10d-d175-4186-85d7-9c06235ea5c5n@googlegroups.com> <tt6rbr$1pkqc$1@dont-email.me>
<410fa1b3-de17-49a6-9ab4-740fc7546a38n@googlegroups.com> <a6334787-03bd-43cb-a600-a935831efc72n@googlegroups.com>
<fb841003-5837-4094-b5cb-e826b9156c4an@googlegroups.com> <622f4169-0b86-4ef9-96cd-a2ede98a5b53n@googlegroups.com>
<e53b8493-b668-45e9-a13f-9cd7622d5e54n@googlegroups.com> <f89b7f3e-46fd-4ed9-a091-2a7cbd8569adn@googlegroups.com>
<20230309120746.4e35005129f964b86a4de87f@g{oogle}mail.com> <tuvu72$1iiar$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <a8712cee-21f9-4910-9566-f87f1a70d774n@googlegroups.com>
Subject: Re: pointers are evil (mostly)
From: edproc...@gmail.com (Ed Prochak)
Injection-Date: Fri, 17 Mar 2023 21:18:42 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 2914
 by: Ed Prochak - Fri, 17 Mar 2023 21:18 UTC

On Thursday, March 16, 2023 at 4:29:39 PM UTC-4, olcott wrote:
> On 3/9/2023 3:07 AM, Anton Shepelev wrote:
> > Ed Prochak:
> >
> >> cases where pointers make much cleaner and more
> >> maintainable code (linked lists, trees)
> >
> > The simplest approach to such lists or trees involves
> > allocating each element with a separate malloc() call. Does
> > it provide sufficient performance is the majority of
> > production code?
> >
> The memory leak errors made possible by pointers can be easily
> eliminated by compiling the code as C++ and using the standard template
> library for all memory allocation.
>
> --
> Copyright 2023 Olcott "Talent hits a target no one else can hit; Genius
> hits a target no one else can see." Arthur Schopenhauer

Suggesting other languages is one solution. In that case why not
C#, java, ...

But we are discussing in comp.lang.c
Memory leaks are possible in C because it expects a skilled programmer.
C doesn't hold your hand. Good code reviews help.

Ed

Re: pointers are evil (mostly)

<tv4v1p$2j9qs$2@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=25089&group=comp.lang.c#25089

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: polco...@gmail.com (olcott)
Newsgroups: comp.lang.c
Subject: Re: pointers are evil (mostly)
Date: Sat, 18 Mar 2023 13:14:16 -0500
Organization: A noiseless patient Spider
Lines: 37
Message-ID: <tv4v1p$2j9qs$2@dont-email.me>
References: <41bb299a-3bf2-4064-9f54-75bcc81fb12en@googlegroups.com>
<0f13b041-8675-4ce5-aa98-f9604b87f7d3n@googlegroups.com>
<a3e126a4-d38d-4071-ade5-752b20aacbe6n@googlegroups.com>
<93bdd10d-d175-4186-85d7-9c06235ea5c5n@googlegroups.com>
<tt6rbr$1pkqc$1@dont-email.me>
<410fa1b3-de17-49a6-9ab4-740fc7546a38n@googlegroups.com>
<a6334787-03bd-43cb-a600-a935831efc72n@googlegroups.com>
<fb841003-5837-4094-b5cb-e826b9156c4an@googlegroups.com>
<622f4169-0b86-4ef9-96cd-a2ede98a5b53n@googlegroups.com>
<e53b8493-b668-45e9-a13f-9cd7622d5e54n@googlegroups.com>
<f89b7f3e-46fd-4ed9-a091-2a7cbd8569adn@googlegroups.com>
<20230309120746.4e35005129f964b86a4de87f@g{oogle}mail.com>
<tuvu72$1iiar$1@dont-email.me>
<a8712cee-21f9-4910-9566-f87f1a70d774n@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Sat, 18 Mar 2023 18:14:17 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="610acb0f773d704d22548a3cd13607fe";
logging-data="2729820"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/+KiNgT21cKoGp77u3X99y"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.8.0
Cancel-Lock: sha1:jpMkcM8DWVVTwqFfNQCM2jvY7hs=
Content-Language: en-US
In-Reply-To: <a8712cee-21f9-4910-9566-f87f1a70d774n@googlegroups.com>
 by: olcott - Sat, 18 Mar 2023 18:14 UTC

On 3/17/2023 4:18 PM, Ed Prochak wrote:
> On Thursday, March 16, 2023 at 4:29:39 PM UTC-4, olcott wrote:
>> On 3/9/2023 3:07 AM, Anton Shepelev wrote:
>>> Ed Prochak:
>>>
>>>> cases where pointers make much cleaner and more
>>>> maintainable code (linked lists, trees)
>>>
>>> The simplest approach to such lists or trees involves
>>> allocating each element with a separate malloc() call. Does
>>> it provide sufficient performance is the majority of
>>> production code?
>>>
>> The memory leak errors made possible by pointers can be easily
>> eliminated by compiling the code as C++ and using the standard template
>> library for all memory allocation.
>>
>> --
>> Copyright 2023 Olcott "Talent hits a target no one else can hit; Genius
>> hits a target no one else can see." Arthur Schopenhauer
>
> Suggesting other languages is one solution. In that case why not
> C#, java, ...
>
> But we are discussing in comp.lang.c
> Memory leaks are possible in C because it expects a skilled programmer.
> C doesn't hold your hand. Good code reviews help.
>
> Ed

It is a bad idea to leave the tediousness of pointers to humans this
simply makes code much more error prone.

--
Copyright 2023 Olcott "Talent hits a target no one else can hit; Genius
hits a target no one else can see." Arthur Schopenhauer

Re: pointers are evil (mostly)

<tv55g6$2kgqc$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=25090&group=comp.lang.c#25090

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: nos...@please.ty (jak.)
Newsgroups: comp.lang.c
Subject: Re: pointers are evil (mostly)
Date: Sat, 18 Mar 2023 21:04:25 +0100
Organization: A noiseless patient Spider
Lines: 37
Message-ID: <tv55g6$2kgqc$1@dont-email.me>
References: <41bb299a-3bf2-4064-9f54-75bcc81fb12en@googlegroups.com>
<0f13b041-8675-4ce5-aa98-f9604b87f7d3n@googlegroups.com>
<a3e126a4-d38d-4071-ade5-752b20aacbe6n@googlegroups.com>
<93bdd10d-d175-4186-85d7-9c06235ea5c5n@googlegroups.com>
<tt6rbr$1pkqc$1@dont-email.me>
<410fa1b3-de17-49a6-9ab4-740fc7546a38n@googlegroups.com>
<a6334787-03bd-43cb-a600-a935831efc72n@googlegroups.com>
<fb841003-5837-4094-b5cb-e826b9156c4an@googlegroups.com>
<622f4169-0b86-4ef9-96cd-a2ede98a5b53n@googlegroups.com>
<e53b8493-b668-45e9-a13f-9cd7622d5e54n@googlegroups.com>
<f89b7f3e-46fd-4ed9-a091-2a7cbd8569adn@googlegroups.com>
<20230309120746.4e35005129f964b86a4de87f@g{oogle}mail.com>
<tuvu72$1iiar$1@dont-email.me>
<a8712cee-21f9-4910-9566-f87f1a70d774n@googlegroups.com>
<tv4v1p$2j9qs$2@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Sat, 18 Mar 2023 20:04:23 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="de47b7b64904effaceff0744ff30e98a";
logging-data="2769740"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19+ZR3pBxVJ41AO1l6Tp/99"
User-Agent: Thunderbird
Cancel-Lock: sha1:ArJx6fJgUgDeTQUtv56CP0PPgO4=
In-Reply-To: <tv4v1p$2j9qs$2@dont-email.me>
 by: jak. - Sat, 18 Mar 2023 20:04 UTC

Il 18/03/2023 19:14, olcott ha scritto:
> On 3/17/2023 4:18 PM, Ed Prochak wrote:
>> On Thursday, March 16, 2023 at 4:29:39 PM UTC-4, olcott wrote:
>>> On 3/9/2023 3:07 AM, Anton Shepelev wrote:
>>>> Ed Prochak:
>>>>
>>>>> cases where pointers make much cleaner and more
>>>>> maintainable code (linked lists, trees)
>>>>
>>>> The simplest approach to such lists or trees involves
>>>> allocating each element with a separate malloc() call. Does
>>>> it provide sufficient performance is the majority of
>>>> production code?
>>>>
>>> The memory leak errors made possible by pointers can be easily
>>> eliminated by compiling the code as C++ and using the standard template
>>> library for all memory allocation.
>>>
>>> --
>>> Copyright 2023 Olcott "Talent hits a target no one else can hit; Genius
>>> hits a target no one else can see." Arthur Schopenhauer
>>
>> Suggesting other languages is one solution. In that case why not
>> C#, java, ...
>>
>> But we are discussing in comp.lang.c
>> Memory leaks are possible in C because it expects a skilled programmer.
>> C doesn't hold your hand. Good code reviews help.
>>
>> Ed
>
> It is a bad idea to leave the tediousness of pointers to humans this
> simply makes code much more error prone.
>

'Oh, you aren't even ripe yet! I don't need any sour grapes.'

Re: pointers are evil (mostly)

<f8bd568a-6b0b-45ba-9d16-fed7a625d137n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=25091&group=comp.lang.c#25091

  copy link   Newsgroups: comp.lang.c
X-Received: by 2002:a05:622a:408:b0:3d5:3d76:df74 with SMTP id n8-20020a05622a040800b003d53d76df74mr2758879qtx.0.1679172130576;
Sat, 18 Mar 2023 13:42:10 -0700 (PDT)
X-Received: by 2002:a05:6902:1143:b0:b6a:5594:5936 with SMTP id
p3-20020a056902114300b00b6a55945936mr63199ybu.5.1679172130219; Sat, 18 Mar
2023 13:42:10 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.c
Date: Sat, 18 Mar 2023 13:42:09 -0700 (PDT)
In-Reply-To: <tv4v1p$2j9qs$2@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=2600:1700:5f82:5000:45b0:2f87:247e:83df;
posting-account=3ty6FAkAAACYEfch20jQ1ZACFatw-Vdx
NNTP-Posting-Host: 2600:1700:5f82:5000:45b0:2f87:247e:83df
References: <41bb299a-3bf2-4064-9f54-75bcc81fb12en@googlegroups.com>
<0f13b041-8675-4ce5-aa98-f9604b87f7d3n@googlegroups.com> <a3e126a4-d38d-4071-ade5-752b20aacbe6n@googlegroups.com>
<93bdd10d-d175-4186-85d7-9c06235ea5c5n@googlegroups.com> <tt6rbr$1pkqc$1@dont-email.me>
<410fa1b3-de17-49a6-9ab4-740fc7546a38n@googlegroups.com> <a6334787-03bd-43cb-a600-a935831efc72n@googlegroups.com>
<fb841003-5837-4094-b5cb-e826b9156c4an@googlegroups.com> <622f4169-0b86-4ef9-96cd-a2ede98a5b53n@googlegroups.com>
<e53b8493-b668-45e9-a13f-9cd7622d5e54n@googlegroups.com> <f89b7f3e-46fd-4ed9-a091-2a7cbd8569adn@googlegroups.com>
<20230309120746.4e35005129f964b86a4de87f@g{oogle}mail.com>
<tuvu72$1iiar$1@dont-email.me> <a8712cee-21f9-4910-9566-f87f1a70d774n@googlegroups.com>
<tv4v1p$2j9qs$2@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <f8bd568a-6b0b-45ba-9d16-fed7a625d137n@googlegroups.com>
Subject: Re: pointers are evil (mostly)
From: edproc...@gmail.com (Ed Prochak)
Injection-Date: Sat, 18 Mar 2023 20:42:10 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
 by: Ed Prochak - Sat, 18 Mar 2023 20:42 UTC

On Saturday, March 18, 2023 at 2:14:33 PM UTC-4, olcott wrote:
> On 3/17/2023 4:18 PM, Ed Prochak wrote:
> > On Thursday, March 16, 2023 at 4:29:39 PM UTC-4, olcott wrote:
[]
> >> The memory leak errors made possible by pointers can be easily
> >> eliminated by compiling the code as C++ and using the standard template
> >> library for all memory allocation.

> >
> > Suggesting other languages is one solution. In that case why not
> > C#, java, ...
> >
> > But we are discussing in comp.lang.c
> > Memory leaks are possible in C because it expects a skilled programmer.
> > C doesn't hold your hand. Good code reviews help.
> >
> > Ed
> It is a bad idea to leave the tediousness of pointers to humans this
> simply makes code much more error prone.

Then you better not program in assembly! Like Fir, you claim it is bad simple because
some people have trouble with it. If you feel that way, join the C++ newsgroup and
stop trying to change C into another language.

I have used C successfully for decades. I have fixed the memory leaks of others.
All in the embedded programming environment. It can be done correctly.

Ed

Re: pointers are evil (mostly)

<e2bdc9bc-7ad5-4756-bc7a-e48578124ab8n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=25092&group=comp.lang.c#25092

  copy link   Newsgroups: comp.lang.c
X-Received: by 2002:ad4:5907:0:b0:5c3:11b6:a116 with SMTP id ez7-20020ad45907000000b005c311b6a116mr647024qvb.9.1679172213482;
Sat, 18 Mar 2023 13:43:33 -0700 (PDT)
X-Received: by 2002:a81:1904:0:b0:542:927b:1c79 with SMTP id
4-20020a811904000000b00542927b1c79mr4836412ywz.3.1679172213195; Sat, 18 Mar
2023 13:43:33 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.c
Date: Sat, 18 Mar 2023 13:43:32 -0700 (PDT)
In-Reply-To: <tv55g6$2kgqc$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=2600:1700:5f82:5000:45b0:2f87:247e:83df;
posting-account=3ty6FAkAAACYEfch20jQ1ZACFatw-Vdx
NNTP-Posting-Host: 2600:1700:5f82:5000:45b0:2f87:247e:83df
References: <41bb299a-3bf2-4064-9f54-75bcc81fb12en@googlegroups.com>
<0f13b041-8675-4ce5-aa98-f9604b87f7d3n@googlegroups.com> <a3e126a4-d38d-4071-ade5-752b20aacbe6n@googlegroups.com>
<93bdd10d-d175-4186-85d7-9c06235ea5c5n@googlegroups.com> <tt6rbr$1pkqc$1@dont-email.me>
<410fa1b3-de17-49a6-9ab4-740fc7546a38n@googlegroups.com> <a6334787-03bd-43cb-a600-a935831efc72n@googlegroups.com>
<fb841003-5837-4094-b5cb-e826b9156c4an@googlegroups.com> <622f4169-0b86-4ef9-96cd-a2ede98a5b53n@googlegroups.com>
<e53b8493-b668-45e9-a13f-9cd7622d5e54n@googlegroups.com> <f89b7f3e-46fd-4ed9-a091-2a7cbd8569adn@googlegroups.com>
<20230309120746.4e35005129f964b86a4de87f@g{oogle}mail.com>
<tuvu72$1iiar$1@dont-email.me> <a8712cee-21f9-4910-9566-f87f1a70d774n@googlegroups.com>
<tv4v1p$2j9qs$2@dont-email.me> <tv55g6$2kgqc$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <e2bdc9bc-7ad5-4756-bc7a-e48578124ab8n@googlegroups.com>
Subject: Re: pointers are evil (mostly)
From: edproc...@gmail.com (Ed Prochak)
Injection-Date: Sat, 18 Mar 2023 20:43:33 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
 by: Ed Prochak - Sat, 18 Mar 2023 20:43 UTC

On Saturday, March 18, 2023 at 4:04:38 PM UTC-4, jak. wrote:
> Il 18/03/2023 19:14, olcott ha scritto:
[]
> > It is a bad idea to leave the tediousness of pointers to humans this
> > simply makes code much more error prone.
> >
> 'Oh, you aren't even ripe yet! I don't need any sour grapes.'

Nice!
Ed

Re: pointers are evil (mostly)

<tv5bum$2lj1v$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=25093&group=comp.lang.c#25093

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: polco...@gmail.com (olcott)
Newsgroups: comp.lang.c
Subject: Re: pointers are evil (mostly)
Date: Sat, 18 Mar 2023 16:54:28 -0500
Organization: A noiseless patient Spider
Lines: 47
Message-ID: <tv5bum$2lj1v$1@dont-email.me>
References: <41bb299a-3bf2-4064-9f54-75bcc81fb12en@googlegroups.com>
<0f13b041-8675-4ce5-aa98-f9604b87f7d3n@googlegroups.com>
<a3e126a4-d38d-4071-ade5-752b20aacbe6n@googlegroups.com>
<93bdd10d-d175-4186-85d7-9c06235ea5c5n@googlegroups.com>
<tt6rbr$1pkqc$1@dont-email.me>
<410fa1b3-de17-49a6-9ab4-740fc7546a38n@googlegroups.com>
<a6334787-03bd-43cb-a600-a935831efc72n@googlegroups.com>
<fb841003-5837-4094-b5cb-e826b9156c4an@googlegroups.com>
<622f4169-0b86-4ef9-96cd-a2ede98a5b53n@googlegroups.com>
<e53b8493-b668-45e9-a13f-9cd7622d5e54n@googlegroups.com>
<f89b7f3e-46fd-4ed9-a091-2a7cbd8569adn@googlegroups.com>
<20230309120746.4e35005129f964b86a4de87f@g{oogle}mail.com>
<tuvu72$1iiar$1@dont-email.me>
<a8712cee-21f9-4910-9566-f87f1a70d774n@googlegroups.com>
<tv4v1p$2j9qs$2@dont-email.me>
<f8bd568a-6b0b-45ba-9d16-fed7a625d137n@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Sat, 18 Mar 2023 21:54:30 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="610acb0f773d704d22548a3cd13607fe";
logging-data="2804799"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/uTGlPGBxOMkOWIyUlat8U"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.8.0
Cancel-Lock: sha1:P9hr44gHBX5sScapJTrF33eVrp4=
In-Reply-To: <f8bd568a-6b0b-45ba-9d16-fed7a625d137n@googlegroups.com>
Content-Language: en-US
 by: olcott - Sat, 18 Mar 2023 21:54 UTC

On 3/18/2023 3:42 PM, Ed Prochak wrote:
> On Saturday, March 18, 2023 at 2:14:33 PM UTC-4, olcott wrote:
>> On 3/17/2023 4:18 PM, Ed Prochak wrote:
>>> On Thursday, March 16, 2023 at 4:29:39 PM UTC-4, olcott wrote:
> []
>>>> The memory leak errors made possible by pointers can be easily
>>>> eliminated by compiling the code as C++ and using the standard template
>>>> library for all memory allocation.
>
>>>
>>> Suggesting other languages is one solution. In that case why not
>>> C#, java, ...
>>>
>>> But we are discussing in comp.lang.c
>>> Memory leaks are possible in C because it expects a skilled programmer.
>>> C doesn't hold your hand. Good code reviews help.
>>>
>>> Ed
>> It is a bad idea to leave the tediousness of pointers to humans this
>> simply makes code much more error prone.
>
> Then you better not program in assembly! Like Fir, you claim it is bad simple because
> some people have trouble with it. If you feel that way, join the C++ newsgroup and
> stop trying to change C into another language.
>

I am agreeing with the original post. Also I wrote my own std::vector in
"C" many years ago so this can be done in C.

In all the years since I switched from C to C++ I only use the standard
library and classes/objects. I still use printf().

OOP is a much better paradigm in that it eliminates the possibility of
global side effects and decomposes functionality into much more easily
understood self-contained units.

> I have used C successfully for decades. I have fixed the memory leaks of others.
> All in the embedded programming environment. It can be done correctly.
>
> Ed

--
Copyright 2023 Olcott "Talent hits a target no one else can hit; Genius
hits a target no one else can see." Arthur Schopenhauer

Re: pointers are evil (mostly)

<tv5esc$2m1u6$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=25094&group=comp.lang.c#25094

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: nos...@please.ty (jak.)
Newsgroups: comp.lang.c
Subject: Re: pointers are evil (mostly)
Date: Sat, 18 Mar 2023 23:44:30 +0100
Organization: A noiseless patient Spider
Lines: 41
Message-ID: <tv5esc$2m1u6$1@dont-email.me>
References: <41bb299a-3bf2-4064-9f54-75bcc81fb12en@googlegroups.com>
<0f13b041-8675-4ce5-aa98-f9604b87f7d3n@googlegroups.com>
<a3e126a4-d38d-4071-ade5-752b20aacbe6n@googlegroups.com>
<93bdd10d-d175-4186-85d7-9c06235ea5c5n@googlegroups.com>
<tt6rbr$1pkqc$1@dont-email.me>
<410fa1b3-de17-49a6-9ab4-740fc7546a38n@googlegroups.com>
<a6334787-03bd-43cb-a600-a935831efc72n@googlegroups.com>
<fb841003-5837-4094-b5cb-e826b9156c4an@googlegroups.com>
<622f4169-0b86-4ef9-96cd-a2ede98a5b53n@googlegroups.com>
<e53b8493-b668-45e9-a13f-9cd7622d5e54n@googlegroups.com>
<f89b7f3e-46fd-4ed9-a091-2a7cbd8569adn@googlegroups.com>
<20230309120746.4e35005129f964b86a4de87f@g{oogle}mail.com>
<tuvu72$1iiar$1@dont-email.me>
<a8712cee-21f9-4910-9566-f87f1a70d774n@googlegroups.com>
<tv4v1p$2j9qs$2@dont-email.me>
<f8bd568a-6b0b-45ba-9d16-fed7a625d137n@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Sat, 18 Mar 2023 22:44:28 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="de47b7b64904effaceff0744ff30e98a";
logging-data="2820038"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1++Uefp6sf1uIwU1axzEsJm"
User-Agent: Thunderbird
Cancel-Lock: sha1:KOZznobF//94KslcqFJoSxy+0p0=
In-Reply-To: <f8bd568a-6b0b-45ba-9d16-fed7a625d137n@googlegroups.com>
 by: jak. - Sat, 18 Mar 2023 22:44 UTC

Il 18/03/2023 21:42, Ed Prochak ha scritto:
> On Saturday, March 18, 2023 at 2:14:33 PM UTC-4, olcott wrote:
>> On 3/17/2023 4:18 PM, Ed Prochak wrote:
>>> On Thursday, March 16, 2023 at 4:29:39 PM UTC-4, olcott wrote:
> []
>>>> The memory leak errors made possible by pointers can be easily
>>>> eliminated by compiling the code as C++ and using the standard template
>>>> library for all memory allocation.
>
>>>
>>> Suggesting other languages is one solution. In that case why not
>>> C#, java, ...
>>>
>>> But we are discussing in comp.lang.c
>>> Memory leaks are possible in C because it expects a skilled programmer.
>>> C doesn't hold your hand. Good code reviews help.
>>>
>>> Ed
>> It is a bad idea to leave the tediousness of pointers to humans this
>> simply makes code much more error prone.
>
> Then you better not program in assembly! Like Fir, you claim it is bad simple because
> some people have trouble with it. If you feel that way, join the C++ newsgroup and
> stop trying to change C into another language.
>
> I have used C successfully for decades. I have fixed the memory leaks of others.
> All in the embedded programming environment. It can be done correctly.
>
> Ed

Believe me, insisting is useless. They don't want to understand what
they themselves are saying. Using C++ instead of C to avoid memory leaks
is probably the right thing to do and as such I advise them to continue
using C++. But C++ isn't C. In C, if you want to increase the
probability of not leaking memory, you just don't use functions like
malloc directly but wrap them in functions that help you properly free
what you allocate. If you don't do at least that, then you don't have
the right mindset to be a C writer.

ps: like you, I've been using C for several decades.

Re: pointers are evil (mostly)

<tv7q30$351ku$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=25101&group=comp.lang.c#25101

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: polco...@gmail.com (olcott)
Newsgroups: comp.lang.c
Subject: Re: pointers are evil (mostly)
Date: Sun, 19 Mar 2023 15:07:59 -0500
Organization: A noiseless patient Spider
Lines: 62
Message-ID: <tv7q30$351ku$1@dont-email.me>
References: <41bb299a-3bf2-4064-9f54-75bcc81fb12en@googlegroups.com>
<0f13b041-8675-4ce5-aa98-f9604b87f7d3n@googlegroups.com>
<a3e126a4-d38d-4071-ade5-752b20aacbe6n@googlegroups.com>
<93bdd10d-d175-4186-85d7-9c06235ea5c5n@googlegroups.com>
<tt6rbr$1pkqc$1@dont-email.me>
<410fa1b3-de17-49a6-9ab4-740fc7546a38n@googlegroups.com>
<a6334787-03bd-43cb-a600-a935831efc72n@googlegroups.com>
<fb841003-5837-4094-b5cb-e826b9156c4an@googlegroups.com>
<622f4169-0b86-4ef9-96cd-a2ede98a5b53n@googlegroups.com>
<e53b8493-b668-45e9-a13f-9cd7622d5e54n@googlegroups.com>
<f89b7f3e-46fd-4ed9-a091-2a7cbd8569adn@googlegroups.com>
<20230309120746.4e35005129f964b86a4de87f@g{oogle}mail.com>
<tuvu72$1iiar$1@dont-email.me>
<a8712cee-21f9-4910-9566-f87f1a70d774n@googlegroups.com>
<tv4v1p$2j9qs$2@dont-email.me>
<f8bd568a-6b0b-45ba-9d16-fed7a625d137n@googlegroups.com>
<tv5esc$2m1u6$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Sun, 19 Mar 2023 20:08:00 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="b26832caf05e3bc993edea855e93ab7d";
logging-data="3311262"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19ikrACJk82T7o5dxesx3vm"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.8.0
Cancel-Lock: sha1:10jzwGoqIxcmlweyPVLzfQs+uBM=
In-Reply-To: <tv5esc$2m1u6$1@dont-email.me>
Content-Language: en-US
 by: olcott - Sun, 19 Mar 2023 20:07 UTC

On 3/18/2023 5:44 PM, jak. wrote:
> Il 18/03/2023 21:42, Ed Prochak ha scritto:
>> On Saturday, March 18, 2023 at 2:14:33 PM UTC-4, olcott wrote:
>>> On 3/17/2023 4:18 PM, Ed Prochak wrote:
>>>> On Thursday, March 16, 2023 at 4:29:39 PM UTC-4, olcott wrote:
>> []
>>>>> The memory leak errors made possible by pointers can be easily
>>>>> eliminated by compiling the code as C++ and using the standard
>>>>> template
>>>>> library for all memory allocation.
>>
>>>>
>>>> Suggesting other languages is one solution. In that case why not
>>>> C#, java, ...
>>>>
>>>> But we are discussing in comp.lang.c
>>>> Memory leaks are possible in C because it expects a skilled programmer.
>>>> C doesn't hold your hand. Good code reviews help.
>>>>
>>>> Ed
>>> It is a bad idea to leave the tediousness of pointers to humans this
>>> simply makes code much more error prone.
>>
>> Then you better not program in assembly! Like Fir, you claim it is bad
>> simple because
>> some people have trouble with it. If you feel that way, join the C++
>> newsgroup and
>> stop trying to change C into another language.
>>
>> I have used C successfully for decades. I have fixed the memory leaks
>> of others.
>> All in the embedded programming environment. It can be done correctly.
>>
>> Ed
>
> Believe me, insisting is useless. They don't want to understand what
> they themselves are saying. Using C++ instead of C to avoid memory leaks
> is probably the right thing to do and as such I advise them to continue
> using C++. But C++ isn't C. In C, if you want to increase the
> probability of not leaking memory, you just don't use functions like
> malloc directly but wrap them in functions that help you properly free
> what you allocate. If you don't do at least that, then you don't have
> the right mindset to be a C writer.
>
> ps: like you, I've been using C for several decades.
>

Personally I have always hated the tediousness pointers so much that I
never used dynamic memory allocation until I found std::vector in C++.

The issue of clean memory management in C might remain a problem because
C has no destructors that are automatically invoked even when you
forget. Maybe there is some way to do this in C?

Calling your own memory management subsystem might be able to somehow
keep track of pointers that are no longer referenced.

--
Copyright 2023 Olcott "Talent hits a target no one else can hit; Genius
hits a target no one else can see." Arthur Schopenhauer

Re: pointers are evil (mostly)

<tv97da$3f9gf$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=25103&group=comp.lang.c#25103

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail
From: nos...@please.ty (jak)
Newsgroups: comp.lang.c
Subject: Re: pointers are evil (mostly)
Date: Mon, 20 Mar 2023 10:01:30 +0100
Organization: A noiseless patient Spider
Lines: 64
Message-ID: <tv97da$3f9gf$1@dont-email.me>
References: <41bb299a-3bf2-4064-9f54-75bcc81fb12en@googlegroups.com>
<0f13b041-8675-4ce5-aa98-f9604b87f7d3n@googlegroups.com>
<a3e126a4-d38d-4071-ade5-752b20aacbe6n@googlegroups.com>
<93bdd10d-d175-4186-85d7-9c06235ea5c5n@googlegroups.com>
<tt6rbr$1pkqc$1@dont-email.me>
<410fa1b3-de17-49a6-9ab4-740fc7546a38n@googlegroups.com>
<a6334787-03bd-43cb-a600-a935831efc72n@googlegroups.com>
<fb841003-5837-4094-b5cb-e826b9156c4an@googlegroups.com>
<622f4169-0b86-4ef9-96cd-a2ede98a5b53n@googlegroups.com>
<e53b8493-b668-45e9-a13f-9cd7622d5e54n@googlegroups.com>
<f89b7f3e-46fd-4ed9-a091-2a7cbd8569adn@googlegroups.com>
<20230309120746.4e35005129f964b86a4de87f@g{oogle}mail.com>
<tuvu72$1iiar$1@dont-email.me>
<a8712cee-21f9-4910-9566-f87f1a70d774n@googlegroups.com>
<tv4v1p$2j9qs$2@dont-email.me>
<f8bd568a-6b0b-45ba-9d16-fed7a625d137n@googlegroups.com>
<tv5esc$2m1u6$1@dont-email.me> <tv7q30$351ku$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Mon, 20 Mar 2023 09:01:30 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="a33d572ff7c6da4b290e08f0c1a3c600";
logging-data="3646991"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19ltpig2RKIg598+KMdtlTo"
User-Agent: Thunderbird
Cancel-Lock: sha1:Zily85NKCjowv3Q3sfQXYI74Lf4=
In-Reply-To: <tv7q30$351ku$1@dont-email.me>
 by: jak - Mon, 20 Mar 2023 09:01 UTC

Il 19/03/2023 21:07, olcott ha scritto:
> On 3/18/2023 5:44 PM, jak. wrote:
>> Il 18/03/2023 21:42, Ed Prochak ha scritto:
>>> On Saturday, March 18, 2023 at 2:14:33 PM UTC-4, olcott wrote:
>>>> On 3/17/2023 4:18 PM, Ed Prochak wrote:
>>>>> On Thursday, March 16, 2023 at 4:29:39 PM UTC-4, olcott wrote:
>>> []
>>>>>> The memory leak errors made possible by pointers can be easily
>>>>>> eliminated by compiling the code as C++ and using the standard
>>>>>> template
>>>>>> library for all memory allocation.
>>>
>>>>>
>>>>> Suggesting other languages is one solution. In that case why not
>>>>> C#, java, ...
>>>>>
>>>>> But we are discussing in comp.lang.c
>>>>> Memory leaks are possible in C because it expects a skilled
>>>>> programmer.
>>>>> C doesn't hold your hand. Good code reviews help.
>>>>>
>>>>> Ed
>>>> It is a bad idea to leave the tediousness of pointers to humans this
>>>> simply makes code much more error prone.
>>>
>>> Then you better not program in assembly! Like Fir, you claim it is
>>> bad simple because
>>> some people have trouble with it. If you feel that way, join the C++
>>> newsgroup and
>>> stop trying to change C into another language.
>>>
>>> I have used C successfully for decades. I have fixed the memory leaks
>>> of others.
>>> All in the embedded programming environment. It can be done correctly.
>>>
>>> Ed
>>
>> Believe me, insisting is useless. They don't want to understand what
>> they themselves are saying. Using C++ instead of C to avoid memory leaks
>> is probably the right thing to do and as such I advise them to continue
>> using C++. But C++ isn't C. In C, if you want to increase the
>> probability of not leaking memory, you just don't use functions like
>> malloc directly but wrap them in functions that help you properly free
>> what you allocate. If you don't do at least that, then you don't have
>> the right mindset to be a C writer.
>>
>> ps: like you, I've been using C for several decades.
>>
>
> Personally I have always hated the tediousness pointers so much that I
> never used dynamic memory allocation until I found std::vector in C++.
>
> The issue of clean memory management in C might remain a problem because
> C has no destructors that are automatically invoked even when you
> forget. Maybe there is some way to do this in C?
>
> Calling your own memory management subsystem might be able to somehow
> keep track of pointers that are no longer referenced.
>
>

So you will have to continue using C++. C is the wrong language for your
needs.

Re: pointers are evil (mostly)

<tva47f$3k480$2@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=25106&group=comp.lang.c#25106

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail
From: vir.camp...@invalid.invalid (Vir Campestris)
Newsgroups: comp.lang.c
Subject: Re: pointers are evil (mostly)
Date: Mon, 20 Mar 2023 17:13:19 +0000
Organization: A noiseless patient Spider
Lines: 10
Message-ID: <tva47f$3k480$2@dont-email.me>
References: <41bb299a-3bf2-4064-9f54-75bcc81fb12en@googlegroups.com>
<0f13b041-8675-4ce5-aa98-f9604b87f7d3n@googlegroups.com>
<a3e126a4-d38d-4071-ade5-752b20aacbe6n@googlegroups.com>
<93bdd10d-d175-4186-85d7-9c06235ea5c5n@googlegroups.com>
<tt6rbr$1pkqc$1@dont-email.me>
<410fa1b3-de17-49a6-9ab4-740fc7546a38n@googlegroups.com>
<a6334787-03bd-43cb-a600-a935831efc72n@googlegroups.com>
<fb841003-5837-4094-b5cb-e826b9156c4an@googlegroups.com>
<622f4169-0b86-4ef9-96cd-a2ede98a5b53n@googlegroups.com>
<e53b8493-b668-45e9-a13f-9cd7622d5e54n@googlegroups.com>
<f89b7f3e-46fd-4ed9-a091-2a7cbd8569adn@googlegroups.com>
<20230309120746.4e35005129f964b86a4de87f@g{oogle}mail.com>
<tuvu72$1iiar$1@dont-email.me>
<a8712cee-21f9-4910-9566-f87f1a70d774n@googlegroups.com>
<tv4v1p$2j9qs$2@dont-email.me>
<f8bd568a-6b0b-45ba-9d16-fed7a625d137n@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Mon, 20 Mar 2023 17:13:19 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="7261e92dc7056c0f9d641ca9576c5656";
logging-data="3805440"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18eGtKKsQV4+S6gy3RbktyPDAC7C1IFHmE="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
Thunderbird/102.8.0
Cancel-Lock: sha1:cGnto3fGtPkRxhwTuLDzXg9GlA8=
Content-Language: en-GB
In-Reply-To: <f8bd568a-6b0b-45ba-9d16-fed7a625d137n@googlegroups.com>
 by: Vir Campestris - Mon, 20 Mar 2023 17:13 UTC

On 18/03/2023 20:42, Ed Prochak wrote:
> I have used C successfully for decades. I have fixed the memory leaks of others.
> All in the embedded programming environment. It can be done correctly.

When I have used C in recent years it has been for embedded platforms.

C++ relies on lots and lots of libraries, and they don't always fit. Nor
are they necessarily available at all times.

Andy

Re: pointers are evil (mostly)

<tval52$3n7am$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=25107&group=comp.lang.c#25107

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail
From: nos...@please.ty (jak)
Newsgroups: comp.lang.c
Subject: Re: pointers are evil (mostly)
Date: Mon, 20 Mar 2023 23:02:09 +0100
Organization: A noiseless patient Spider
Lines: 122
Message-ID: <tval52$3n7am$1@dont-email.me>
References: <41bb299a-3bf2-4064-9f54-75bcc81fb12en@googlegroups.com>
<0f13b041-8675-4ce5-aa98-f9604b87f7d3n@googlegroups.com>
<a3e126a4-d38d-4071-ade5-752b20aacbe6n@googlegroups.com>
<93bdd10d-d175-4186-85d7-9c06235ea5c5n@googlegroups.com>
<tt6rbr$1pkqc$1@dont-email.me>
<410fa1b3-de17-49a6-9ab4-740fc7546a38n@googlegroups.com>
<a6334787-03bd-43cb-a600-a935831efc72n@googlegroups.com>
<fb841003-5837-4094-b5cb-e826b9156c4an@googlegroups.com>
<622f4169-0b86-4ef9-96cd-a2ede98a5b53n@googlegroups.com>
<e53b8493-b668-45e9-a13f-9cd7622d5e54n@googlegroups.com>
<f89b7f3e-46fd-4ed9-a091-2a7cbd8569adn@googlegroups.com>
<20230309120746.4e35005129f964b86a4de87f@g{oogle}mail.com>
<tuvu72$1iiar$1@dont-email.me>
<a8712cee-21f9-4910-9566-f87f1a70d774n@googlegroups.com>
<tv4v1p$2j9qs$2@dont-email.me>
<f8bd568a-6b0b-45ba-9d16-fed7a625d137n@googlegroups.com>
<tv5esc$2m1u6$1@dont-email.me> <tv7q30$351ku$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Mon, 20 Mar 2023 22:02:10 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="5e632d5159379fd022ae943168d3ec14";
logging-data="3906902"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18KpkMQ2vxYTEX5RfV9umNp"
User-Agent: Thunderbird
Cancel-Lock: sha1:mxO4L8CsteZ3qnLvupPGhFoh4o8=
In-Reply-To: <tv7q30$351ku$1@dont-email.me>
 by: jak - Mon, 20 Mar 2023 22:02 UTC

Il 19/03/2023 21:07, olcott ha scritto:
> On 3/18/2023 5:44 PM, jak. wrote:
>> Il 18/03/2023 21:42, Ed Prochak ha scritto:
>>> On Saturday, March 18, 2023 at 2:14:33 PM UTC-4, olcott wrote:
>>>> On 3/17/2023 4:18 PM, Ed Prochak wrote:
>>>>> On Thursday, March 16, 2023 at 4:29:39 PM UTC-4, olcott wrote:
>>> []
>>>>>> The memory leak errors made possible by pointers can be easily
>>>>>> eliminated by compiling the code as C++ and using the standard
>>>>>> template
>>>>>> library for all memory allocation.
>>>
>>>>>
>>>>> Suggesting other languages is one solution. In that case why not
>>>>> C#, java, ...
>>>>>
>>>>> But we are discussing in comp.lang.c
>>>>> Memory leaks are possible in C because it expects a skilled
>>>>> programmer.
>>>>> C doesn't hold your hand. Good code reviews help.
>>>>>
>>>>> Ed
>>>> It is a bad idea to leave the tediousness of pointers to humans this
>>>> simply makes code much more error prone.
>>>
>>> Then you better not program in assembly! Like Fir, you claim it is
>>> bad simple because
>>> some people have trouble with it. If you feel that way, join the C++
>>> newsgroup and
>>> stop trying to change C into another language.
>>>
>>> I have used C successfully for decades. I have fixed the memory leaks
>>> of others.
>>> All in the embedded programming environment. It can be done correctly.
>>>
>>> Ed
>>
>> Believe me, insisting is useless. They don't want to understand what
>> they themselves are saying. Using C++ instead of C to avoid memory leaks
>> is probably the right thing to do and as such I advise them to continue
>> using C++. But C++ isn't C. In C, if you want to increase the
>> probability of not leaking memory, you just don't use functions like
>> malloc directly but wrap them in functions that help you properly free
>> what you allocate. If you don't do at least that, then you don't have
>> the right mindset to be a C writer.
>>
>> ps: like you, I've been using C for several decades.
>>
>
> Personally I have always hated the tediousness pointers so much that I
> never used dynamic memory allocation until I found std::vector in C++.
>
> The issue of clean memory management in C might remain a problem because
> C has no destructors that are automatically invoked even when you
> forget. Maybe there is some way to do this in C?
>
> Calling your own memory management subsystem might be able to somehow
> keep track of pointers that are no longer referenced.
>
>

C++ makes heavy use of dynamic memory even if this thing is masqueraded,
this is why destructors exist and are needed. But remember that an
executable produced with C++ needs a runtimer and much more memory to
run compared to executables produced by C. However, if you really need a
destructor function in C, then you could create it yourself. Obviously
this function would not do anything automatically and this could be the
way:

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/wait.h>

char *ptr = NULL;

void kill_foo()
{ free(ptr);
ptr = NULL;
}

int foo()
{ if(fork())
return

atexit(kill_foo);

char f[] = "%s %s", h[] = "hello", w[] = "world";
int len = 1 + snprintf(NULL, 0, f, h, w);

ptr = malloc(len);
snprintf(ptr, len ,f, h, w);
if(ptr)
printf("foo: %s\n", ptr);
else
printf("foo: null ptr\n");

exit(0);
}

int main()
{ foo();
wait(NULL);

if(ptr)
printf("main: %s\n", ptr);
else
printf("main: null ptr\n");

exit(0);
}

Of course it's just sample code and I don't check the return values.
You'll probably think it's a complicated way but don't think that what
C++ masks you is very different. I often read about comparisons between
C and C++ but they are not comparable because they are two different
languages and similar only in syntax. Speaking absurdly I could say that
it is more logical to compare C-Sharp and Visual-Basic.

Pages:12
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor