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:17

>>18
"well at least I shown some code"
I didn't say or imply that even once. Tell me, why do you think I posted that code? I've stated it explicitly numerous times, so you don't need to trouble yourself with finding subtext.

Yes. Doing so is good.
No, it's not. C++ broke away from being a mere C pre-proccesor for a reason. There's no way back, and even Bjarn will tell you that choosing to build on C was a difficult compromise. You can't write good C that way.

That's why we can't have nice things.
Speak for yourself. I have lots of nice things.

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