|
Understood.
My point is asking for zero bytes of memory gets me an OK (not a NULL) whether I use calloc or malloc.
I have problems with that behavior.
I realize that it's saying I got what I wanted.
Checking for NULL is not a guaranteed successful approach.
Instead one should be checking for non-zero allocation parameters prior to calling malloc or calloc!
"A little time, a little trouble, your better day"
Badfinger
|
|
|
|
|
Testing to see what actually happens is a good idea.
But never forget: "Implementation dependent" does not mean "The way gcc implements it" (or any other given compiler), even though gcc users often seems to think that way. Any other C compiler may think differently.
|
|
|
|
|
I agree.
"A little time, a little trouble, your better day"
Badfinger
|
|
|
|
|
The testing showed me that using calloc and malloc requires some extra checking for zero memory requests.
As a result, I am scanning my uses of it in my older code. I do not think I inadvertently allocated zero memory, I want to be sure. BTW malloc and calloc return NULL when memory requested is less than zero.
"A little time, a little trouble, your better day"
Badfinger
|
|
|
|
|
Behavior for the first one is implementation defined[^].
Meanwhile, the second is just a weird way of saying null.
Am I missing something?
Mircea
|
|
|
|
|
agree,
GNU GCC
BTW can you id the background in my photo. Hint Canada
"A little time, a little trouble, your better day"
Badfinger
modified 13-Dec-22 1:11am.
|
|
|
|
|
jmaida wrote: GNU GCC
Not quite. malloc() is provided by libc. For most linux distributions, that will be provided by GNU libc, but it doesn't have to be.
Keep Calm and Carry On
|
|
|
|
|
jmaida wrote: BTW can you id the background in my photo. Hint Canada
Not really: you are too big and skyline is too small. Looks like "city by the water" but that's not narrowing it much
Mircea
|
|
|
|
|
Behind is Detriot River and Canada @ Angstrom Park, part of Amherstburg, just north of Crystal Island.
"A little time, a little trouble, your better day"
Badfinger
|
|
|
|
|
mwh, standards shmandereds. They both return null.
To err is human. Fortune favors the monsters.
|
|
|
|
|
char* sz = (char*)(strchr("1",'0' + 1) - strchr("1",'0' + 1));
Now ask some C++ guru, how to make this constexpr .
|
|
|
|
|
I'm wondering if it is a subversive campaign to create a SoapBox?
I’ve given up trying to be calm. However, I am open to feeling slightly less agitated.
|
|
|
|
|
Or are you just thin-skinned at _this_ moment?
|
|
|
|
|
There's a much more simple answer.
I'm trying to get my Rep Numbers boosted.
I'm currently at 125.9K & I've heard that when I reach 126K (or greater) -- seems arbitrary but it's true -- that CP will be sending me a check for $1USD per point.
I'm quite excited.
I believe @chris-maunder hand delivers the check to your home, so I'll meet a Star too!!
|
|
|
|
|
I have some really bad news for you ...
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
I would be happy enough if I got a CP Coffee mug to make my co-worker envious
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
Rating helpful answers is nice, but saying thanks can be even nicer.
|
|
|
|
|
I think any Protector who has never received a CP coffee mug should be sent one.
|
|
|
|
|
I second that
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
Rating helpful answers is nice, but saying thanks can be even nicer.
|
|
|
|
|
I have too many. I could send you one maybe, but you're not in the US are you?
To err is human. Fortune favors the monsters.
|
|
|
|
|
Nope, I am in Germany.
Thank you anyways
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
Rating helpful answers is nice, but saying thanks can be even nicer.
|
|
|
|
|
Actually it's Sean in a mankini. You'll need to talk to him about the cheque. It may be that you get the actual mankini instead.
cheers
Chris Maunder
|
|
|
|
|
I figured folks have invested in popcorn suppliers. :popcorn:
|
|
|
|
|
#Worldle #325 2/6 (100%)
🟩🟩⬜⬜⬜⬅️
🟩🟩🟩🟩🟩🎉
https://worldle.teuteuf.fr
"A little time, a little trouble, your better day"
Badfinger
|
|
|
|
|
I typically keep a /notes folder under my professional work such that I can write down pertinent things that come up as the project progresses such as technical points from a phone conversation relevant to the completing the software project (what hardware driver ICs are being used for example)
It does a few things. It keeps me organized, and keeps my notes safely in source control. It also keeps things handy for other people I work with to go through.
It's very simple to do, and it has proven invaluable to me time and again.
To err is human. Fortune favors the monsters.
|
|
|
|
|
I've recently started doing something similar. I also add any repos that I need to complete the project/ticket. I'm working in Windows 10 and really miss using grep to parse the files. It can still be done and I probably need to learn some regex to make PowerShell more effective.
Do you format your files in any particular way? Do you use different files for different notes, like each day gets it own file or do you just stick it all in one?
I'm still working on my process at this point, but it seems to work reasonably well for me, so far.
Ron
Jack of all trades, master of none, though often times better than master of one.
|
|
|
|