| Deutsch English Français Italiano |
|
<vm1np5$1fn6n$1@dont-email.me> View for Bookmarking (what is this?) Look up another Usenet article |
Path: news.eternal-september.org!eternal-september.org!.POSTED!not-for-mail
From: "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com>
Newsgroups: comp.lang.c
Subject: Re: So You Think You Can Const?
Date: Sun, 12 Jan 2025 16:46:29 -0800
Organization: A noiseless patient Spider
Lines: 83
Message-ID: <vm1np5$1fn6n$1@dont-email.me>
References: <vljvh3$27msl$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Mon, 13 Jan 2025 01:46:29 +0100 (CET)
Injection-Info: dont-email.me; posting-host="7cf9ff7908854d51543addd9ba101a96";
logging-data="1563863"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+4G/rwYp4MwOFY5lqZ0Gh4btjbs2QKbXg="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:K969TGPIZLZRWSIZKkFs13xYFHw=
Content-Language: en-US
In-Reply-To: <vljvh3$27msl$1@dont-email.me>
On 1/7/2025 11:32 AM, Julio Di Egidio wrote:
> Hi everybody,
>
> I am back to programming in C after many years:
> indeed I have forgotten so many things, including
> how much I love this language. :)
From reading this thread I take it you would prefer this style:
______________________
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <inttypes.h>
int main()
{
int* a = malloc(sizeof(*a));
if (! a)
{
// shit happens! ;^o
return EXIT_FAILURE;
}
// okay...
*a = 42;
printf("a = %p\n", (void*)a);
printf("*a = %d\n", *a);
uintptr_t x = (uintptr_t)a;
free(a);
printf("x = %" PRIxPTR " was just freed! do not deref\n", x);
return 0;
}
______________________
over this thing:
______________________
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <inttypes.h>
int main()
{
int* a = malloc(sizeof(*a));
if (a)
{
*a = 42;
printf("a = %p\n", (void*)a);
printf("*a = %d\n", *a);
uintptr_t x = (uintptr_t)a;
free(a);
printf("x = %" PRIxPTR " was just freed! do not deref\n", x);
return EXIT_SUCCESS;
}
return EXIT_FAILURE;
}
______________________
? Am I on the right track with your form? Say you were reviewing by
code. Bad, or really bad!
;^)
[...]