Y
HN Search
Hacker News Search
new
|
comments
|
top
|
jobs
xcgvgh
searching PlanetScale…
1.
▲
2.
▲
3.
▲
4.
▲
5.
▲
6.
▲
4 ms
·
1.
▲
by
xcgvgh
11y ago
It's also very dangerous.
2.
▲
by
xcgvgh
11y ago
There is no reinventing going on here. In C you have to write relatively low level code. This includes manually calling allocs for objects, which includes the code for checking your arithmetic. At some point you will have to write that code
3.
▲
by
xcgvgh
11y ago
Using calloc instead of malloc, just for checking arithmetic overflow, is superfluous. You can always write a check or a wrapper for malloc that does that automatically. It is so easy I can write it here: _Bool Check( const size_t a , c
4.
▲
by
xcgvgh
11y ago
The assignment is a conversion from unsigned to signed, if the value cannot be represented by the signed type, the result is implementation defined or an implementation defined signal is triggered.
5.
▲
by
xcgvgh
11y ago
I understand. If I change the argument to: size_t is capable of holding the largest array index" , then this must be correct, or is there still something I missed?
6.
▲
by
xcgvgh
11y ago
>size_t is defined as "an integer capable of holding the >largest array index" >>No, it isn't. Could anyone elaborate? I don't see how could someone allocate more than SIZE_MAX bytes with (m/c/re)al
7.
▲
by
xcgvgh
11y ago
If I'm reading it correctly it got denied because it would be too similar to an already existing trademark: LP LET’S PLAY . Yuck...
8.
▲
by
xcgvgh
11y ago
I apologize. I wasn't aware of extended integer types.
9.
▲
by
xcgvgh
11y ago
There are no such things in the C Standard.
10.
▲
by
xcgvgh
11y ago
Typedef doesn't create a new type, it merely creates a new name for a type. I don't know what you mean by implementation defined integer type. If the implementation is conforming, then any integer type that isn't a basic C
11.
▲
by
xcgvgh
11y ago
With my assumption, it will be defined as an unsigned char, as it should be.
12.
▲
by
xcgvgh
11y ago
In the second to last paragraph; did you hint that wrapping a char*, used as a string, into a struct, to get type safety?
13.
▲
by
xcgvgh
11y ago
I think the whole article needs a preface, assuming CHAR_BIT is defined as 8 .
14.
▲
by
xcgvgh
11y ago
I use long when I need an int that can always represent ranges in -2^31-1 to 2^31-1, no assumptions necessary. Same goes for unsigned versions and long long.
15.
▲
ISIS Gives Us No Choice but to Consider Limits on Speech
(slate.com)
2 points
by
xcgvgh
11y ago
|
0 comments
16.
▲
Philip is creating Handmade Quake, a game dev resource using the Quake source
(patreon.com)
2 points
by
xcgvgh
11y ago
|
0 comments