Conversation started Nov 1, 2011 at 16:47.
sbi
sbi
Nov 1, 2011 16:47
Does anyone feel up to the task of writing an FAQ about not using malloc() and free() in C++?
The question is rather weak though.
@sbi I'll give it a go
sbi
sbi
@awoodland Ha, I was just asking. :)
@awoodland Did you see the fine print I put under all the FAQ questions? It helped getting them "tolerated".
@RMartinhoFernandes Indeed.
@RMartinhoFernandes That answer is pretty good, but might be a bit too focused on vector for being used in a malloc vs. new FAQ.
@awoodland Oh, wait! Search first! I can't believe this hasn't been answered before!
35
Q: What is the difference between new/delete and malloc/free?

MrDatabaseWhat is the difference between new/delete and malloc/free? Related (duplicate?): In what cases do I use malloc vs new?

sbi
sbi
Nov 1, 2011 16:54
27
Q: In what cases do I use malloc vs new?

I am new to C++ programming but have a solid background in C#, Java and PHP. I see in C++ there are multiple ways to allocate and free data and I understand that when you call malloc you should call free and when you use the new operator you should pair with delete and it is a mistake to mix the...

This is even better.
@awoodland, do you copy?
@awoodland WTF, there's an answer from the FQA there.
@sbi - yes, I see
I searched the tag earlier, possibly that last one should be retagged
It's full of "comments as answers". I'm flagging them for removal.
I also think such a FAQ should mention that you should not use naked news and should have them in resource managing classes instead.
There's also a "peculiar" history there...
sbi
sbi
@awoodland I just searched the links of related questions to it, and it seems this is the master the others got closed as dupes of.
Maybe we should set a bounty on it for a grandiose FAQ-worthy answer.
sbi
sbi
Nov 1, 2011 16:59
@RMartinhoFernandes Ouch. OTOH, it's water under the bridge now.
Als
Als
Hello Gents.
sbi
sbi
@RMartinhoFernandes You mean, ask the question again, and wait for good answers to trickle in, while promising a bounty to raise the quality? That's a good idea – except that the question will be closed immediately as a dupe.
@sbi Well, I meant a bounty on that question. I think the question is good, but I'm not entirely satisfied by the existing answer.
Als
Als
@RMartinhoFernandes: Which one?
sbi
sbi
@RMartinhoFernandes Oh, I see. Mhmm.
Nov 1, 2011 17:02
27
Q: In what cases do I use malloc vs new?

I am new to C++ programming but have a solid background in C#, Java and PHP. I see in C++ there are multiple ways to allocate and free data and I understand that when you call malloc you should call free and when you use the new operator you should pair with delete and it is a mistake to mix the...

sbi
sbi
@RMartinhoFernandes I always prefered FAQ entries to have an accepted answer, but maybe that's not as good and important as I thought it is?
@RMartinhoFernandes What is this???
Als
Als
The new keyword is the C++ way of doing it, and it will ensure that your type will have their constructor called. The new keyword is also more type safe whereas malloc is not typesafe at all.
@sbi Well, that question can never get an accepted answer now. The asker was nuked for his weird editing behaviour.
Als
Als
Only these two lines in the answer talk about new over malloc
@sbi It's one of the reasons available for bounties.
sbi
sbi
Nov 1, 2011 17:04
@RMartinhoFernandes I know. Hence my statement.
@RMartinhoFernandes You can give a reason for a bounty?
Yes.
It's also possible to write your own.
sbi
sbi
@RMartinhoFernandes When I click on "start a bounty", I don't see any way to give a reason... Ah, I didn't dare to click on "Next" before. That seems good.
sbi
sbi
Well, I'd be willing to spend 500rep on a bounty for this. What do you guys think?
Als
Als
What are we expecting here as answer?
Nov 1, 2011 17:07
Well, I was willing to do the same, but I won't stop you :)
sbi
sbi
@Als "Canonical answer required"
can you not double bounty a question?
sbi
sbi
@RMartinhoFernandes I have more rep to spare than you.
@awoodland Good idea. Lemme check...
A question can have three simultaneous bounties.
sbi
sbi
@awoodland No, it seems you can't. At least I cannot start a bounty on this question.
Nov 1, 2011 17:09
@sbi I'm way past 20k now, there are no more thresholds.
sbi
sbi
@RMartinhoFernandes I'm past 20k 2.5 times. :)
Oh, then I read that wrong.
Probably means a user can have bounties on three questions.
sbi
sbi
@RMartinhoFernandes Yes, that's how I understood this.
> You can start a total of 3 simultaneous bounties.
Right, that's actually pretty clear.
Silly me.
sbi
sbi
@RMartinhoFernandes A silly robot? Now that deserves a star!
Nov 1, 2011 17:12
lol
I think we should explain in the custom bounty message that this is for the C++ FAQ, and what we are expecting from it.
sbi
sbi
@RMartinhoFernandes Absolutely.
And I suggest we pin a message here directing the regulars towards it.
Mhmm. I just had another idea...
sbi
sbi
We could also add a CW'd answer and all collaborate on it.
But this would need >54 upvotes to pass the so-far best answer, plus any upvotes that one will catch once we start drawing attention to the question.
Does an answer that has gained a bounty rise above the others?
Not unless it gets more votes.
sbi
sbi
Nov 1, 2011 17:16
@RMartinhoFernandes So we'd need more upvotes anyway, even with the bounty.
I'm sure an answer worthy of the bounty would rise up.
A big fat bounty draws a lot of attention.
vs install requires SECOND reboot. how silly. for an application
stackoverflow.com/questions/184537/… - that was on the right question in the end?
sbi
sbi
@RMartinhoFernandes Yeah, and I don't really worry about losing 500rep. What I am worried about, though, is that we might attract many, many answers with a bounty, many of which might be pretty good, but none definitive.
@sbi That's why we need to make that clear in the bounty description.
sbi
sbi
Nov 1, 2011 17:19
@RMartinhoFernandes Shrug. So? People won't magically provide a definitive answer just because you request one.
They will!
:(
Damn pessimists.
Als
Als
I doubt there is going to be an definitive answer.
You too, Brutus Als?
Als
Als
I like @sbi suggestion of making it a CW and collaborating on it to answer it definitively.
sbi
sbi
@RMartinhoFernandes I'm not a pessimist, but I'm too old to not to be a realist!
@Als That has drawbacks, too, though. For example, while many of us here are good enough to provide a good answer, that does by no means guarantee that we can collaboratively come up with a good answer. The result might be of frustratingly low quality, or this room might actually die in a horrible flame war, because we cannot agree on something.
Nov 1, 2011 17:24
dons asbestos longjohns
I'm ready.
Yay! Sci-Fi rep is trickling in :)
Als
Als
@sbi: We Come up with one,We can then review if it is good enough(Let it stay, and take comments),and if we feel it is not definitive we let it stay and then start a bounty, that way the bounty hopefuls will be willing to meet the deficiencies of that answer.
 
Conversation ended Nov 1, 2011 at 17:26.