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 14:51

>>21
Tell me, why do you think I posted that code?
Because you came up with one of the most braindamaged ways to implement >>4, overcame a number of difficulties along the way and decided to share the experience.

Which would be a good and noble thing to do, if not for the fact that you are a very bad programmer, an intellectual cripple, a freak of nature produced by overexposure to C and underexposure to other system languages.

The code in >>12 doesn't have any of the difficulties that you advised about dealing with in >>7. None at all! Hard to believe, I know, but try to find a single advice of yours that applies to my code!

Which means that your post a) doesn't contain any useful advice, b) does contain horrible, misleading code, that can further spread the intellectual corruption and desolation that you are plagued with. It is worse than useless, it has negative worth.

You can't write good C that way.
I write code this way. My code is good. You write "idiomatic C" code. Your code is beyond terrible. But by all means, continue ignoring the reality in favor of your infallible logical proofs, you'll fit right in /autism/.

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