Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

C memory management

Name: Anonymous 2011-02-12 5:42

Hey /prog, I'm teaching myself C by writing a roguelike and I noticed that C uses manual memory management for creating objects in the heap. I was wondering if the C-gods could lend me some advice on how to proceed with this:

I want to write a roguelike with thousands of NPCs, every NPC is a really small piece of data which does not contain any pointers (position, stats, behavior... probably ends up being a few bytes). NPCs would spawn and die constantly. How would I go about managing the memory for this?

• malloc and free individual NPCs
• Boehm-Demers-Weiser conservative garbage collector
• malloc a big chunk of memory and build some kind of memory manager on top of it (are there techniques for this?)

Please advice.

Name: Anonymous 2011-02-12 13:58

>>14
Without more help than you've given he's likely to produce something buggy, unclear and downright wrong.
And with your "help" he is guaranteed to produce something buggy, ugly and downright wrong. Because your code is based on the most retarded C-ism in existence. Try to apply your advices to my code. It is impossible. The problems simply don't exist.

Are you familiar with the term "net-negative producing programmer" (http://en.wikipedia.org/wiki/NNPP)? That's you my friend, and your "help" is the prime example of that, it has negative worth. OP would have been better off without it. So that entire "well at least I shown some code" thing you seem to be pushing is wrong, showing code that bad is worse than showing no code at all.

Meanwhile, you're actually advocating using C++isms in C. That's what earned you the Linus remark.
Yes. Doing so is good. There is a lot of good C++isms. Good C programmers use them all the time. Go look at the fucking Linux networking code. There's a lot of awful C-isms. Only learning C++ can save you from writing retarded C. Go do it and don't write a line of C before you are done, for the sake of humanity!

I am paid well and I often earn compliments from my employer and coworkers regarding the quality of the code I write.
That's why we can't have nice things.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List